[TYPO3-dam] Getting the uid of the Media folder
georg kuehnberger
georg at georg.org
Tue Mar 18 00:39:38 CET 2008
Ahoi Francois,
Francois Suter wrote:
> Hi all,
> I was wondering whether there was a canonical way of getting the uid of
> the Media sysFolder?
Thanks for your question! I asked that one myself too often, though was
too lazy to investigate and resorted back to setting the PID via the
EXT-Config of my new extensions.
I'm trying to insert records into the DAM from an
> extension and I obviously need to set the pid inside the tx_dam record.
OK
> I know I could just query the page table for a page called "Media", but
better not, as
- Pagetitle "Media" is not unique and can be renamed anyway;
- better might be something like:
SELECT uid FROM pages WHERE module = dam
but still not good enough as there might be multiple occurences of this
one, too.
> I thought that there's maybe a helper function for that in the DAM.
> Cheers
Thanks to your interest I finally looked it up and luckily here we go,
see below:
regards georg
something like
tx_dam_db::getPid()
should do fine
see:
dam/lib/class.tx_dam_db.php
---
/**
* Returns a single pid of a DAM folder.
* This pid have to be used for storage of DAM records.
*
* For fetching data getPidList() have to be used.
*
* @return integer Current/default DAM folder pid for storage.
*/
function getPid () {
global $TYPO3_CONF_VARS;
static $pid = 0;
if(!$pid AND is_object($GLOBALS['TSFE'])) {
// get pid from TS
//
// plugin.tx_dam.defaults {
// // The pid of the media folder. Needs to be set when multiple
media folders exist
// pid =
$pid = intval(tx_dam::config_getValue('plugin.defaults.pid')); #
$GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_dam.']['defaults.']['pid']);
}
if(!$pid) {
require_once(PATH_txdam.'lib/class.tx_dam_sysfolder.php');
$pid = tx_dam_sysfolder::init();
}
return $pid;
}
More information about the TYPO3-project-dam
mailing list