Extension Development, add a startingpoint
From TYPO3Wiki
<< Back to Extension Development << Back to Developer manuals page
Startingpoint
How to add a startingpoint
The current settings for pages and recursivity are in $this->cObj->data. The plugin base class provides a method pi_getPidList() to transform both data in a comma separated string:
$pidList = $this->pi_getPidList($this->cObj->data['pages'], $this->cObj->data['recursive']); //if "pages" contains 312 and 313, and 314 is below 313 // and recursive is set to 1, $pidList will be // 312,313,314
Now we may use MySQL's IN operator to make sure we select only records on the desired pages.
We also use t3lib_DB::cleanIntList() to stay safe of sql injections:
// Get resource records: $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( "*", "tx_myext_table", "pid IN (" . $GLOBALS['TYPO3_DB']->cleanIntList($selectedPids) . ")" . " AND my_criteria=" . $criteria//extend that as you like ); //displaying retrieved records while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $content.= "found record uid=".$row['uid']; }
Speed improvements
You can do like this if you want to hardcode the sql statement and avoid recursion and gain some speed:
$this->andWhere('uid' => '666'); $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( '*,V.title VT,V.uid VU,S.title ST,S.uid SU,S1.uid S1U, S1.title S1T, S2.uid S2U, S2.title S2T', 'pages WA INNER JOIN pages V ON WA.pid=V.uid INNER JOIN pages S ON V.pid=S.uid INNER JOIN pages S1 ON S.pid=S1.uid INNER JOIN pages S2 ON S1.pid=S2.uid', 'S2.uid='..$GLOBALS['TYPO3_DB']->cleanIntList($parentUid).' AND WA.deleted=0 AND WA.hidden=0'.(count($this->andWhere)?' AND '.implode(' AND ',$this->andWhere):'').(count($this->orWhere)?' AND ('.implode(' OR ',$this->orWhere).')':''), 'S1.uid','WA.pid','');
--Chibox 15:38, 12 February 2008 (CET)
