[TYPO3] menuFunc

Bas van der Togt bas.vander.togt at efocus.nl
Mon Jul 9 13:00:12 CEST 2007


Thank you very much for your help Peter!
It works perfect!

Cheers,
Bas

Peter Klein wrote:
> Hi Bas. 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.
> 
> The new PHP class/function
> -- 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 --
> page.includeLibs.menustuff = fileadmin/menuFunc2.inc
> 
> obj.header = HMENU
> obj.header.special = userfunction
> obj.header.special.userFunc = user_menuFunc->makeMenuArray
> obj.header.special.userFunc.table = tx_ablinklist_category
> obj.header.special.userFunc.select.pidInList = 91
> obj.header.special.userFunc.actextkey = tx_ablinklist_pi1
> obj.header.special.userFunc.actextvar = category_uid
> obj.header.1 = TMENU
> obj.header.1 {
>    NO {
>      doNotLinkIt = 0
>      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
>    ACT = 1
>    ACT.allWrap = <b>|</b><br>
> }
> 
> page.7911 < obj.header
> -- cut --
> 
> 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.
> 
> 


More information about the TYPO3-english mailing list