[Typo3] Doing a select statement from typoscript

Ries van Twisk typo3 at rvt.dds.nl
Thu Sep 29 19:28:05 CEST 2005


Peter Klein wrote:

>Hi Ries. I think you'll have to write a small userFunc. That way you have 
>full control of SQL. 1You could then return a list of IDs, and then process 
>them further by using typoscript..
>
>---
>Peter Klein/Umloud Untd.
>
>  
>
Hey peter,

I came to that conclusion myself to...

it's not optimized or anything yet but I currently do something like this:
so I only get all pages below my current page (needs to be in rootline).

function ts_latestPages ($conf=array()) {
        t3lib_div::print_array($conf);
        //                           exec_SELECTquery ($select_fields, 
$from_table, $where_clause, $groupBy=', $orderBy=', $limit=')
        $sys_page = t3lib_div::makeInstance("t3lib_pageSelect");

        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','pages','', 
'', 'crdate DESC', '');
        $menu = array(); $count = 0;
        while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) && 
($count<7)) {
            $rootLine = $sys_page->getRootLine($row['uid']);
            foreach ($rootLine AS $key => $value) {
                if ($GLOBALS['TSFE']->id == $value['pid']) {
                    $menu[] = $row;
                    $count++;
                    break;
                }
            }
        }
        return $menu;
    }



More information about the TYPO3-english mailing list