[TYPO3-english] treeLevel = -1

JoH asenau info at cybercraft.de
Wed Mar 10 18:22:02 CET 2010


> I normally want to have menu A on every page, except when the page is
> on the last level of the current rootline, then I want menu B. The
> last level of the rootline is unknown, it could be level 3 in one
> part of the tree and level 7 in another part.

So you want to replace menu A with menu B, as soon as there are no subpages
available.
After all it's not that hard do explain ;-)

Solution:

temp.defaultmenu = HMENU
temp.defaultmenu {
  entryLevel = -1
  1 = TMENU
  1 {
    wrap = <ul>|</ul>
    NO {
      wrapItemAndSub = <li>|</li>
    }
  }
}

temp.mymenu < temp.defaultmenu
temp.mymenu {
  stdWrap.ifEmpty.cObject < temp.defaultmenu
  stdWrap.ifEmpty.cObject.entryLevel = -2
}

In case the first copy of the default HMENU is empty, another copy of the
same HMENU is used with a different entryLevel. You should use a real HMENU
and check if it's empty instead of i.e. using a check for numRows on the
pages table, since HMENU will always return proper results even in localized
page trees.

The important thing is to have no wrap inside the HMENU but just inside
TMENU and NO, else the first copy of the HMENU will never be "empty" even
without having subpages!

HTH

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Xing: http://contact.cybercraft.de
Twitter: http://twitter.com/bunnyfield
TYPO3 cookbook (2nd edition): http://www.typo3experts.com




More information about the TYPO3-english mailing list