Create menus using data from other tables than "pages"

Submitting your vote...
Rating: 5.0 of 5. 2 vote(s).
Click the rating bar to rate this item.

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.

Tsref, select

 

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


Top 10 Updates

Using lightbox without extension geändert am  13-Jun-2008 14:20:51
Custom field for GMENU alt text geändert am  13-Jun-2008 13:58:07
Extending typoscript properties with stdWrap geändert am  13-Jun-2008 13:54:32
Create menus using data from other tables than "pages" V2  geändert am  24-Mar-2008 13:02:09
Login geändert am  17-Mar-2008 12:47:52
Forum geändert am  17-Mar-2008 10:07:47
Who is Typo3wizard.com geändert am  26-Dec-2007 16:07:32
Menu as un-nested lists (iphone navigation) geändert am  29-Oct-2007 15:05:53
IF Conditions with AND and OR operators geändert am  16-Oct-2007 19:16:04
UserFunc to fix problems with HMENU type "special=updated"  geändert am  16-Oct-2007 18:58:40
Deutsch
Search: