[TYPO3] How to create an updated menu?

Andreas Balzer typo3 at andreas-balzer.de
Tue Jun 12 18:14:40 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
> 
> 
I have a few questions about implementing it..
Is the word menustuff irrelevant? Can I write something like 
pages.includeLibs.sortouthiddenpages?

I have named the file sortouthiddenpages.inc. Do I have to change 
something in the other codes?

Is the following implementation correct?
temp.new = COA
temp.new.10 = HTML
temp.new.10.value = <div class="SpalteBorderKastenBox"><div 
class="SpalteBorderKastenHeadline">&nbsp; &nbsp; Was gibt´s 
Neues?</div><div class="SpalteBorderKastenContent">
temp.new.20 = HMENU
temp.new.20.special = updated
temp.new.20.special.value = 1
temp.new.20.special {
#mode = lastUpdated
mode = tstamp
depth = 9999999999
maxAge = 3600*24*7*8
limit = 5
}
temp.new.20.entryLevel = 0
temp.new.20.1 = TMENU
temp.new.20.1 {
expAll = 1
minItems = 1
maxItems = 5
itemArrayProcFunc = user_menuFunc->hideHiddenSubs
NO {
linkWrap = <b> | </b>
allWrap =  | <BR>
}
}
temp.new.30 = HTML
temp.new.30.value = </div></div>

#temp.new = COA
#temp.new {
#  10 = LOAD_REGISTER
#  10{
#    lvl1uids.cObject = CONTENT
#    lvl1uids.cObject {
#      table=pages
#      select.pidInList.data = leveluid:0
#      select.addWhere = not hidden = 1
#      renderObj = TEXT
#      renderObj.field = uid
#      renderObj.wrap = |,
#      renderObj.stdWrap.crop = 16 | ...
#    }
#    lvl2uids < .lvl1uids
#    lvl2uids.cObject.select.pidInList.data= register:lvl1uids
#    lvl3uids < .lvl1uids
#    lvl3uids.cObject.select.pidInList.data= register:lvl2uids
#    lvl4uids < .lvl1uids
#    lvl4uids.cObject.select.pidInList.data= register:lvl3uids
#    lvl5uids < .lvl1uids
#
#   lvl5uids.cObject.select.pidInList.data= register:lvl4uids
#    alluids.cObject = COA
#    alluids.cObject {
#      10=TEXT
#      10.data = register:lvl1uids
#      20=TEXT
#      20.data = register:lvl2uids
#      30=TEXT
#      30.data = register:lvl3uids
#      40=TEXT
#      40.data = register:lvl4uids
#      50=TEXT
#      50.data = register:lvl5uids
#      60=TEXT
#      60.data = leveluid:0
#    }

   }
   20 = CONTENT
   20 {
     table = pages
     select {
       pidInList.data = register:alluids
       orderBy = tstamp DESC
       max = 5
     }
     renderObj = COA
     renderObj {
       10 = TEXT
       10.field = title
       10.typolink.parameter.field=uid
       10.wrap = <li>|</li>
       10.crop = 16 | ...
     }
   }
   wrap=<div class="SpalteBorderKastenBox"><div 
class="SpalteBorderKastenHeadline">&nbsp; &nbsp; Was gibt´s 
Neues?</div><div class="SpalteBorderKastenContent"><ul 
class="lastchangesmenu">|</ul></div></div>
}


If it's correct then it doesn't work.. :-/

Andreas


More information about the TYPO3-english mailing list