[TYPO3] Create menus using data from table tt_news

Sander van Gelderen reply.t at list.please
Mon Jan 29 14:19:49 CET 2007


Hello List,

I solved part of my problems myself. I added 
'$GLOBALS["TSFE"]->set_no_cache();' to userfunction and removed 
'typolink.parameter.data = field:uid' from template.

Here is my complete userfunction:


<?php
class user_menuFunc {
     function makeMenuArray($content,$conf) {
     	$GLOBALS["TSFE"]->set_no_cache();
         $menuArr = array();
         $lConf = $conf["userFunc."];
         $overridehref = $lConf['_OVERRIDE_HREF'];
         $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)) {
             	
             	$row['_OVERRIDE_HREF'] = 'index.php?id=' . $overridehref 
             				. '&tx_ttnews[tt_news]=' . $row['uid']
             				. '&tx_ttnews[backPid]=4';
             	
                 $menuArr[] = $row;
             }
         }
         return $menuArr;
     }
}
?>

and TS:

page.includeLibs.usermenu = fileadmin/menuFunc.inc

lib.usermenu = HMENU
lib.usermenu.protectLvar = 1
lib.usermenu.wrap = <ul>|</ul>
lib.usermenu.special = userfunction
lib.usermenu.special.userFunc = user_menuFunc->makeMenuArray
lib.usermenu.special.userFunc.table = tt_news
lib.usermenu.special.userFunc.select.pidInList = 102
lib.usermenu.special.userFunc._OVERRIDE_HREF = 34
lib.usermenu.1 = TMENU
lib.usermenu.1 {
	NO {
     		stdWrap.data = field:title
     		# Remove the # from the next line if you want to see which fields 
are available!
     		# stdWrap.data = debug:data
     		# typolink.parameter.data = field:uid
     		allWrap = <li>|</li>
   	}
   	ACT < .NO
         ACT = 1
	ACT {
		ATagParams = class="selected"
	}
}


These are remaining problems for me:

1) I want the url's to follow realurl configuration, is function 
pi_RTEcssText($str) in tslib/class.tslib_pibase.php good for doing this 
with? How could I call such a function from my userfunction?

2) I need to set 'ITEM_STATE' => 'ACT' for the appropriate row. How can 
I check this in my userfunction? depending on the use of realurl or not, 
I need the selected article's id from getParam or some other way.


I would really appreciate your help on this, TIA

Sander



Sander van Gelderen schreef:
> Hello list,
> 
> I have used Peter Klein's execllent example on 
> http://www.typo3wizard.com/en/snippets/menus/create-menus-using-data-from-other-tables-than-pages.html 
> 
> to create a menu that get's it items from tt_news.
> 
> I am having trouble setting the correct href on the menu links. After 
> retrieving the rows i add to the array:
> 
> $row['_OVERRIDE_HREF'] = 'index.php?id=' . $overridehref .
>              '&tx_ttnews[tt_news]=' . $row['uid'] .
>                      '&tx_ttnews[backPid]=4';
> 
> The href does link to the correct page, but the news detail does not get 
> displayed. What is missing from these parameters is the cHash I suppose, 
> is this the problem and how can I obtain the cHash value?
> 
> TIA for any advice,
> 
> Sander
> 
> 


More information about the TYPO3-english mailing list