Changing Menu based on selected Templavoila TemplateObject using TypoScript

TypoScript has so much features that it is indeed impossible to document each and every feature hidden with it. As we start adding extensions the feature list would increase as well.

Consider you have selected a specific Templavoila Template and you wish to have a different type of menu based on the selected template.
In such case it would be easy to change menu styles if the entire menu is enclosed in a separate CSS class.

I have given an example where I am checking for template IDs 10 , 11. If this template is used for current page I am changing it’s class.

lib.mymenu = HMENU
lib.mymenu {
entryLevel = 1
stdWrap.ifEmpty.wrap =  

1 = TMENU
1 {
wrap = <ul>|</ul>
NO.wrapItemAndSub = |</li>
NO.allWrap = <li>|
NO.allWrap {
override = <li class=”alternate_menu”>|
override.if.value = 10,11
override.if.isInList.field = tx_templavoila_to
}
# same way we can configure ACT and CUR as well
ACT = 1
CUR = 1

}

# For second level I would like to change the class of the A Tag
2 < .1
2.wrap = <ul>|</ul>
2.CUR.ATagParams = id=”cur_menu”
2.ACT.ATagParams.cObject = TEXT
2.ACT.ATagParams.cObject {
override = class=”cur_menu_a”
override.if.value = 10,11
override.if.isInList.field = tx_templavoila_to
}
3 < .2

#let us generate the 3rd level only if the page uses the Template of our choice.
3.if {
value = 10,11
isInList.field = tx_templavoila_to
}

}

Not all templates may have a template ID specified, in such case we need to use the sliding feature.
When we use the sliding feature the template id of parent ID is used.
We can do this Like:

isInList.data = levelfield:-1, tx_templavoila_to, slide

Note:
Usually Templates are stored in the Storage Folder, and you can view the Template IDs of Templavoila Template Objects from the list view!

How to set ATagParams for menu items (except for some pages)

This code may be useful when you may wish to have some extra parameter to all anchor tags in menu items, the code even shows how you can avoid these parameters for some selected pages.

This code may be useful when you may wish to have some extra parameter to all anchor tags in menu items, the code even shows how you can avoid these parameters for some selected pages.

The code below creates this link:

<a rel=”moodalbox” href=”pagelink” >page title</a>

For pages with uid 10, 23 the link will be generated as follows:

<a href=”pagelink” >page title</a>

To get this kind of menu write the following typoscript in the Setup section:

lib.atl_lefttop = COA
lib.atl_lefttop.10 = HMENU
# Level 1
lib.atl_lefttop.10 {
stdWrap.ifEmpty.wrap = &nbsp;
1 = TMENU
1 {
wrap = <ul>|</ul>
expAll = 1
NO.wrapItemAndSub = <li>|</li>

NO.ATagParams.cObject = TEXT
NO.ATagParams.cObject {
value = rel=moodalbox
/*
moodalbox should not be applied for the uid specified here
*/
if {
value = 10,23
isInList.field = uid
negate = 1
}
}

ACT < NO
ACT.wrapItemAndSub = <li class=”act”>|</li>

CUR < NO
CUR.wrapItemAndSub = <li class=”cur”>|</li>
}

}

# level 2 3 and 4 use same settings as sown above
2< .1
3< .2
4< .3
}