问题
This may sound strange, but I have a menu where the first page has no real subpages. However, it has an appended COA with 2 custom TMENU's and a plugin insertion.
But: The subnavigation for this page is only generated when I add a visible subpage to this page (which would be a workaroud). Is there a better solution to get this menu visible?
Here's the typoscript:
field_main_navigation = HMENU
field_main_navigation {
1 = TMENU
1 {
expAll = 1
NO. wrapItemAndSub = <div class="wrap-itemAndSub">|</div>
ACT < .NO
ACT = 1
ACT.ATagParams = class="active"
}
2 = TMENU
2 {
wrap = <div class="sub clearfix" style="display: none;">|</div>
# Custom build for page 2
stdWrap.wrap.append = COA
stdWrap.wrap.append {
if.value.field = pid
if.equals = 2
# a lot of typoscript, basically:
# two COA's, one with two HMENU, the
# other one with plugin content
10 = COA
# ...
20 = COA
# ...
}
NO = 1
NO {
allWrap = <li>|</li>
}
}
}
To explain what I want to achieve
Basically it is a simple "show submenu on hover". Just the first item
has special content in its hover submenu. Because there are no actual
subpages that [ nav 1 ] contains, no submenu is rendered.
[ nav 1 ] [ nav 2 ] [ nav 3 ]
|------div.sub style="display: none;" *-------|
| ( Custom TMENU ) | (Plugin Content) |
| | |
|--------------------|------------------------|
| ( Custom TMENU ) | ( Usual submenu ** )|
| | |
|---------------------------------------------|
* Pops out when hovering over [ nav 1 ]
** this _may_ be the case in the future, but
currently not. here's the problem
That lead me to another question (just now): Should I do all this in my usual HMENU/TMENU or should I render a normal HMENU/TMENU and prepend nav-1 as a typoscript-generated custom navigation point with custom subnavigation layer?
回答1:
Place your custom content on the first level menu setup. Try this:
field_main_navigation = HMENU
field_main_navigation {
1 = TMENU
1 {
expAll = 1
NO.wrapItemAndSub {
append = COA
append {
if {
value.field = uid
equals = 2
}
# a lot of typoscript, basically:
# two COA's, one with two HMENU, the
# other one with plugin content
10 = COA
# ...
20 = COA
# ...
}
wrap3 = <div class="wrap-itemAndSub">|</div>
}
ACT < .NO
ACT = 1
ACT.ATagParams = class="active"
}
2 = TMENU
2 {
wrap = <div class="sub clearfix" style="display: none;">|</div>
NO = 1
NO {
allWrap = <li>|</li>
}
}
}
NOTE: I'm a bit confused by the wrap on the second TMENU. Do any of the 1st level items have any real subpages?
来源:https://stackoverflow.com/questions/8927420/display-tmenu-2-even-if-it-has-no-submenu-points-but-content