简体   繁体   English

如何在TYPO3中拆分和包装HMENU项目?

[英]How can I split and wrap HMENU items in TYPO3?

I'm trying to create a custom menu with TypoScript, I have 8 Menü items an d I want to remove the css class "dropdown_1column and dropdown_1column" for the first 2 items and I do not know how? 我正在尝试使用TypoScript创建自定义菜单,我有8个菜单项,并且我想删除前2个菜单项的CSS类“ dropdown_1column和dropdown_1column”,但我不知道如何?

I have experienced that it is with the Typoscript onSplit function possible, whats wrong in this code? 我已经体验过Typoscript onSplit函数可能存在的问题,这段代码有什么问题?

 wrap = <ul class="levels">|</ul>|| <ul class="levels">|</ul>|*|<div class="dropdown_1column"><div class="col_1 firstcolumn"><ul class="levels">|</ul></div></div>||<ul class="levels">|</ul>

The first two items should be wrapped in: 前两项应包装在:

 <ul class="levels">|</ul>

The remaining items should be wrapped in: 其余物品应包装在:

 <div class="dropdown_1column"><div class="col_1 firstcolumn"><ul class="levels">|</ul></div></div>

here ist my html output: 这是我的html输出:

<li>
   <a class="drop" href="blblbl/">item</a>
      <div class="dropdown_1column">
          <div class="col_1 firstcolumn">
            <ul class="levels">
               <li>
               <li>
               <li>
            </ul>
      </div>
 </li>

and it must be so 而且一定是这样

<li>
   <a class="drop" href="blblbl/">item</a>
      <div>
          <div>
            <ul class="levels">
               <li>
               <li>
               <li>
            </ul>
      </div>
 </li>

Thank You for Help. 谢谢你的帮助。

You could either go fo optionSplit to format items based on their position or you could split the menu in two parts and use begin and maxItems to define the range of items to use. 您可以使用optionSplit来根据项目的位置设置格式,也可以将菜单分为两部分,并使用begin和maxItems定义要使用的项目范围。

The latter is less sophisticated but should serve you well: 后者不太复杂,但应该可以为您提供良好的服务:

10 = COA
10 {
  10 = HMENU
  10 {
    # your menu definition here
    maxItems = 2
    wrap = <ul class="levels">|</ul>
  }
  20 = HMENU
  20 {
    # your menu definition here
    begin = 3
    wrap = <div class="dropdown_1column"><div class="col_1 firstcolumn"><ul class="levels">|</ul></div></div>
  }
}

Your option split syntax is wrong. 您的选项拆分语法错误。 It must be first |*| middle |*| last 它必须是first |*| middle |*| last first |*| middle |*| last first |*| middle |*| last . first |*| middle |*| last Elements are filed in beginning from last. 元素从头开始归档。 You can further split each property by a double pipe ( || ). 您可以使用双管道( || )进一步拆分每个属性。

first || second |*| middle |*| second last || last

Thus it should be 因此应该

wrap = <ul class="levels">|</ul>|| <ul class="levels">|</ul>|*| <div class="dropdown_1column"><div class="col_1 firstcolumn"><ul class="levels">|</ul></div></div> |*|  <div class="dropdown_1column"><div class="col_1 firstcolumn"><ul class="levels">|</ul></div></div>

which has the format 具有以下格式

first || second |*| middle |*| last

whereas the middle and the last part share the same code 而中间部分和最后部分共享相同的代码

I'd say that no one has read TSref here :) 我会说没有人在这里读过TSref :)

What you need: 您需要什么:

According to 4th rule of optionSplit 1 : 根据optionSplit 1的第4条规则:

"if the last part is absent, the middle value is repeated" “如果没有最后一部分,则重复中间值”

So the most elegant and shortest optionSplit syntax will be: 因此,最优雅,最短的optionSplit语法为:

first || second |*| the_rest

In Typoscript code it will be something like: 在Typoscript代码中,它将类似于:

<ul class="levels">|</ul> || <ul class="levels">|</ul> |*| <div class="dropdown_1column"><div class="col_1 firstcolumn"><ul class="levels">|</ul></div></div>

What you got: 你有什么:

The optionSplit you wrote has syntax like this: 您编写的optionSplit具有如下语法:

F || S |*| M1 || M2

which produces menu like: 产生如下菜单:

F S M1 M2 M1 M2 M1 M2....

because the (the last, or if absent) the middle part is repeated continuously after the first part. 因为中间部分(最后一个,或者如果没有)将在第一部分之后连续重复。

For more about optionSplit . 有关optionSplit的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM