

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




NO {
# doNotLinkIt = 1
stdWrap.data = field:name
# Remove the # from the next line if you want to see which fields are available!
#stdWrap.data = debug:data
typolink.parameter.data = field:www
allWrap = <br>
}
Also the following line:
lib.usermenu.special.userFunc.table = tt_addess
should obviously be:
lib.usermenu.special.userFunc.table = tt_address
Thanks for sharing this one Peter!
This will convert the TYPO3 "Sectionmenu" (which is not a real menu, but just a select query in the tt_content database.), into a real HMENU with optionSplit etc.
-- cut --
page.includeLibs.usermenu = fileadmin/menuFunc.inc
tt_content.menu.20.3 >
tt_content.menu.20.3 = HMENU
tt_content.menu.20.3 {
special = userfunction
special.userFunc = user_menuFunc->makeMenuArray
special.userFunc.table = tt_content
special.userFunc.select.andWhere = sectionIndex!=0 AND header!=''
special.userFunc.select.pidInList.override.field = pages
wrap = <div class="csc-menu csc-menu-3">|</div>
1 = TMENU
1.NO.doNotLinkIt = 1
1.NO.stdWrap.field = header
1.NO.stdWrap.typolink.parameter.field = pid
1.NO.stdWrap.typolink.section.field = uid
1.NO.stdWrap.htmlSpecialChars = 1
1.NO.allWrap = <p class="csc-section">[1]|</p> |*| <p
class="csc-section">[2]|</p> |*| <p class="csc-section">[3]|</p>
}
-- cut --
Add comment