[TYPO3] If main menu doesn't have a submenu ... ?

JoH asenau info at cybercraft.de
Fri May 11 16:39:55 CEST 2007


> How do I check if the current page doesn't have any submenu pages
> under it?
>
> I have created two menus, one main menu on top and a side menu on the
> left side of the content. Problem is when the user clicks on a menu on
> top and it doesn't have any submenus on it the menu at the left side
> will be empty. I would like it to default to get the items above it if
> current level is empty ...
>
> Here's what I have so far.. I know I'm probably doing this wrong...
> I'm actually a bit confused right now on how to use negate and 'if'
> ... :

Well - this is not the scenario for the use of "if" but for "override".
The override property will only override the current content, if there is
some content in the overriding object. So you could do it like this:

temp.siblingMenu = HMENU
temp.siblingMenu {
    entryLevel = -2
    1 = TMENU
    1 {
        wrap = <ul>|</ul>
        NO {
            allWrap = <li>|</li>
        }
    }
}

temp.subpageMenu < temp.siblingMenu
temp.subpageMenu {
    entryLevel = -1
}

temp.mySwitchingMenu = COA
temp.mySwitchingMenu {
    10 < temp.siblingMenu
    stdWrap.override.cObject < temp.subpageMenu
}

This will generate a menu with the siblings of the current page in section
10 of the COA.
Then it will override the whole COA with a menu of the subpages of the
current page but only if there is content in the subpageMenu.
Just be sure to only wrap the TMENU and TMENUITEM parts but not the HMENU
since this would always return at least the wrap as a content.

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
openBC/Xing: http://www.cybercraft.de
T3 cookbook: http://www.typo3experts.com




More information about the TYPO3-english mailing list