Create menus using data from other tables than "pages" V2

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

Here's an updated version of the PHP script, and a new example Typoscript, that tells the PHP script to look for a GET var, and use that value to determine which "page" should be set to active.

 

In the Typoscript for the userFunc, you can now set 2 extra parameters:

 

obj.header.special.userFunc.actextkey = tx_ablinklist_pi1

 

Which sets the extension key of the GET var that should be used to determine the ACT state.

And:

 

obj.header.special.userFunc.actextvar = category_uid

 

Which sets the extension variable of the GET var that should be used to determine the ACT state.

 

 


The new PHP class/function (Save it as "fileadmin/menuFunc2.inc")
-- cut --
<?php

class user_menuFunc {

function 
makeMenuArray($content,$conf) {
$menuArr = array();
$lConf $conf["userFunc."];
$actuid 0;
if (
$lConf['actextkey'] && $lConf['actextvar']) {
$getval t3lib_div::_GET();
$actuid $getval[$lConf['actextkey']][$lConf['actextvar']];
}
$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)) {
if (
$actuid!=&& $actuid==$row['uid']) $row['ITEM_STATE']='ACT';
$menuArr[] = $row;
}
}
return 
$menuArr;
}

}

?>
-- cut --

 

 

The new Typoscript Example:

 

-- cut -- - ERROR: Line 1: Object Name String, "--" was not preceded by any operator, =<>({;Line 43: Object Name String, "--" was not preceded by any operator, =<>({
page.includeLibs.menustuff = fileadmin/menuFunc2.inc

obj.header = HMENU
obj.header.special = userfunction
obj.header.special.userFunc = user_menuFunc->makeMenuArray

# Set the "table" to the DB table you want to use for the menu.
# In this example I use the Modern Linklist (ab_linklist) extension.
obj.header.special.userFunc.table = tx_ablinklist_category

# Here you set the "pidInList" to the location of your DB records.
obj.header.special.userFunc.select.pidInList = 91

# Set "actextkey" to the extension key of the GET var that
# should be used to determine the ACT state.
obj.header.special.userFunc.actextkey = tx_ablinklist_pi1

# Set "" to the extension variable of the GET var that
# should be used to determine the ACT state.
obj.header.special.userFunc.actextvar = category_uid
obj.header.1 = TMENU
obj.header.1 {
  NO {
    doNotLinkIt = 1
    stdWrap.field = label
    stdWrap.typolink.useCacheHash = 1
    stdWrap.typolink.parameter.data = page:uid
    stdWrap.typolink.additionalParams.dataWrap = &tx_ablinklist_pi1[category_uid]={field:uid}
    #stdWrap.data = debug:data
    allWrap = |<br>
  }
  ACT < .NO - ERROR: Line 75: Object copied in this line "ACT < .NO" would leave either the value or properties untouched in TypoScript Version 1. Please check that this is not a problem for you.
  ACT = 1
  ACT.allWrap = <b>|</b><br>
}

page.7911 < obj.header
-- cut -- - ERROR: Line 39: Object Name String, "--" was not preceded by any operator, =<>({;Line 81: Object Name String, "--" was not preceded by any operator, =<>({

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: