


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!=0 && $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, =<>({


Comments (2)