How to use option split to control typo3 menu properties?

孤者浪人 提交于 2019-12-01 13:08:38
pgampe

I do not think a new site should use GMENU any more. Instead you should use TMENU with CSS.

Here is a basic example that should get you started:

10 = HMENU
10 {
  special = directory
    # start with pid 3
  special.value = 3
  1 = TMENU
  1 {
    expAll = 1
    wrap = <ul>|</ul>
    NO = 1
    NO {
      wrapItemAndSub = <li>|</li>
      ATagTitle = abstract // description // title
    }
    ACT < .NO
    ACT.wrapItemAndSub = <li class="active">|</li>
    CUR < .NO
    CUR.wrapItemAndSub = <li class="current">|</li>
  }
  2 < .1
  3 < .1
  4 < .1
  4.wrap = <ul class="level-4">|</li>
}

Of course you can now use option split for wrapItemAndSub like so: wrapItemAndSub = <li class="first">|</li> |*| <li class="normal">|</li> |*| <li class="last">|</li>

The rest in then just normal CSS.

If your problem is that you want to wrap different sub-menues on the same level with different class attributes, then have a look at the submenuObjSuffixes property of the TMENU object.

While it is not possible to use optionsplit with wrap (simply because wrap is only executed once) it is very well possible to get the desired result using submenuObjSuffixes.

Here is an example:

1 = TMENU
1 {
    wrap = <ul>|</ul>
    submenuObjSuffixes =  |*| b |*| c

    NO = 1
    NO {
        wrapItemAndSub = <li>|</li>
    }
}

2 < .1
2.wrap = <ul class="firstItem">|</ul>
2b < .1
2b.wrap = <ul class="middleItems">|</ul>
2c < .1
2c.wrap = <ul class="lastItem">|</ul>

3 < .2
3b < .2b
3c < .2c
4 < .2
4b < .2b
4c < .2c

This will wrap the first 2nd-level menu with class "firstItem", the last 2nd-level menu with "lastItem" and all inbetweens with class "middleItems".

Please understand that the suffixes are appended to ALL subsequent menu levels. So if you use submenuObjSuffixes on level 1 it will not only affect level 2 but also levels 3, 4, ... and you have to define corresponding options on these levels too, or they will not be rendered.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!