[TYPO3] How to create an updated menu?

Andreas Balzer typo3 at andreas-balzer.de
Tue Jun 12 00:39:20 CEST 2007


Peter Klein schrieb:
> "Andreas Balzer" <typo3 at andreas-balzer.de> skrev i en meddelelse 
> news:mailman.1.1181563887.22534.typo3-english at lists.netfielders.de...
>> Peter Klein schrieb:
>>> "Andreas Balzer" <typo3 at andreas-balzer.de> skrev i en meddelelse 
>>> news:mailman.1.1181540209.12155.typo3-english at lists.netfielders.de...
>>>> Peter Klein schrieb:
>>>>> Hi Andreas.
>>>>>
>>>>> On the page you have set to "hidden", enable the checkbox " Include 
>>>>> subpages:". That should get rid of the subpages of hidden pages in your 
>>>>> menu.
>>>> Hi!
>>>> Well that would be an idea, but then non-BE users wouldn't be able to 
>>>> access that page. Isn't it possible to tell TYPO3 to look in the page 
>>>> levels whether one page is hidden?
>>>>
>>> The easiest way would be to write a small UserFunc that checks the 
>>> current menuitem and it's parent item, all the way to the rootline, to 
>>> see if it has "hidden" set. And if it's set, you skip generating that 
>>> menuitem.
>>>
>> Hi :)
>> Any chance to find such a UserFunc somewhere in the internet? ;)
>>
>> Andreas
> 
> Hi Andreas. I haven't seen any, but it can't be that hard to make.. ;)
> 
> Something like this:
> 
> Create a file in your fileadmin folder, and name it "menuFunc.inc"
> Then fill it with this content:
> 
> -- cut --
> <?php
> 
> class user_menuFunc {
> 
>  function hideHiddenSubs($menuArr ,$conf) {
>   $new_menuArr = array();
>   while (list($k,$v) = each($menuArr)) {
>    if (!$this->gethidden($v['uid'])) {
>     $new_menuArr[] = $v;
>    }
>   }
>   return $new_menuArr;
>  }
> 
>  function gethidden($uid) {
>   $hiddenFlag = 0;
>   while ($uid!=0) {
>    $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','pages','uid='.$uid);
>    $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
>    $uid = $row['uid'];
>    $hiddenFlag += $row['hidden'];
>   }
>   return ($hiddenFlag>0);
>  }
> }
> 
> ?>
> -- cut --
> 
> Then in your SETUP field, insert this line:
> 
> -- cut --
> page.includeLibs.menustuff = fileadmin/menuFunc.inc
> -- cut --
> 
> And in your TMENU object, insert this before the NO part:
> 
> -- cut --
> itemArrayProcFunc = user_menuFunc->hideHiddenSubs
> -- cut --
> 
> This will check if the current menuitem or it's parent or (parents parent 
> etc.) pages is hidden, and exclude that from the menu.
> Only problem is that if you set "maxItems =5" then $menuArr only contains 5 
> pages, and if 1 of these is behind a hidden page, only 4 pages will be 
> shown.
> 
> --
> Peter Klein / Umloud Untd
> 
> 
Hi!
Thank you so much :)

Greetings
Andreas


More information about the TYPO3-english mailing list