[TYPO3] userFunc in HMENU not working if the results array is too big (with templavoila)

Olivier Schopfer ops at wcc-coe.org
Fri Jun 27 10:44:57 CEST 2008


It seems that HMENU has a bug when using a userFunc that returns a too 
big array. If the number of results is limited, then it works perfectly. 
If I have  around 350 items, it fails and I get a blank page. Strange 
enough, it doesn't raise an error condition. Moreover, the admin pannel 
is still displayed, and seems to show the proper content of the menu.

Any idea?

Olivier

I have the following typoscript code in a TemplaVoilà data structure for 
a page:

	20 = HMENU
	20.special = userfunction
	20.special.userFunc = 
tx_osprayercyclemenus_pi1->generateFilteredMenuFromList
	20.special.userFunc.field = member_of
	20.special.userFunc.datastructure = 44
	20.special.userFunc.select.selectFields = 
uid,title,nav_title,tx_templavoila_flex
	20.1 = TMENU
	20.1 {
	  NO {
		doNotLinkIt = 0
		stdWrap.field = title
		# Remove the # from the next line if you want to see which fields are 
available!
		#stdWrap.data = debug:data
		#typolink.parameter.field = www
		ATagTitle.field = nav_title // title
		allWrap = <div class="hb_link">|</div>
	  }
	}

And the code of the userFunc is:

/* This function generates a menu out of a subset of pages for which a 
certain templavoila Field list contains a certain value */

function generateFilteredMenuFromList($content,$conf) {
/**
*
* field = field that contains the list (nested)
* datastructure = templavoila datastructure (list, comma separated)
* select.selectFields = list of selected fields do you want.
*
*/
       $local_cObj = t3lib_div::makeInstance('tslib_cObj'); // Local cObj.
       $menuArr = array();
       $subArr = array();
       $lConf = $conf["userFunc."];
       $value = $local_cObj->stdWrap($lConf["value"],$lConf["value."]);
       $res = 
$GLOBALS['TYPO3_DB']->exec_SELECTquery($lConf["select."]["selectFields"],'pages',' 
tx_templavoila_ds IN ( '.$lConf["datastructure"].') ORDER BY title ASC ');
       //t3lib_div::debug($lConf);
       //t3lib_div::debug($lConf["value."]["data"]);

       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)) {
                   $XML = t3lib_div::xml2array($row['tx_templavoila_flex']);

                   if (is_array($XML)) {
                         $subArr = 
$XML['data']['sDEF']['lDEF'][$lConf['field']];

                         if (is_array($subArr['el'])) {
                               foreach ($subArr['el'] as $val) {
                                     $fieldValue = 
$val['list_member_of']['el']['field_link']['vDEF'];
                                     if 
($fieldValue==$GLOBALS["TSFE"]->id) {
                                      unset($row['tx_templavoila_flex']);
                                      $menuArr[] = $row;
                                     }
                               }
                         }
                   }
             }
       }
       return $menuArr;
}


More information about the TYPO3-english mailing list