


Here's a little PHP codesnippet that allows you to use other tables than 'pages' to render menus.
What it does is adding a TS "select" property to the userFunc.. More info on "select" can be found in TSRef.
Create a file in your "fileadmin" folder, and name it "menuFunc.inc", then fill the file with this content:
-- cut --
<?php
class user_menuFunc {
function makeMenuArray($content,$conf) {
$menuArr = array();
$lConf = $conf["userFunc."];
$res = $this->cObj->exec_getQuery($lConf["table"],$lConf["select."]);
if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
$GLOBALS['TT']->setTSlogMessage($error,3);
} else {
$GLOBALS['TT']->setTSlogMessage('NUMROWS: '.$GLOBALS['TYPO3_DB']->sql_num_rows($res));
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$menuArr[] = $row;
}
}
return $menuArr;
}
}
?>
-- cut --
And here's a simple example using the function to create a list of tt_address records in a standard TMENU. (Which could also have been a GMENU)
BTW: Remember to change the "select" statement in the line:
lib.usermenu.special.userFunc.select.pidInList = 4
to point to the sysfolder where your tt_address records are located..
page.includeLibs.usermenu = fileadmin/menuFunc.inc lib.usermenu = HMENU lib.usermenu.special = userfunction lib.usermenu.special.userFunc = user_menuFunc->makeMenuArray lib.usermenu.special.userFunc.table = tt_addess lib.usermenu.special.userFunc.select.pidInList = 4 lib.usermenu.1 = TMENU lib.usermenu.1 { NO { doNotLinkIt = 1 stdWrap.field = user # Remove the # from the next line if you want to see which fields are available! #stdWrap.data = debug:data typolink.parameter.field = www allWrap = <br> } }
This snippet was submitted by Peter Klein


Comments (2)