简体   繁体   English

使用bootstrap_package将部分(锚点)添加到typo3的流畅菜单中

[英]Adding sections (anchors) to a fluid menu in typo3 with bootstrap_package

I would like to have a menu mixing pages and sections from current page. 我想要一个菜单​​,其中包含当前页面中的页面和部分。 For example on page1: 例如在第1页:

  • section1_from_page1 section1_from_page1
  • section2_from_page1 section2_from_page1
  • page2 第2页
  • page3 第3页

And on page2: 并在第2页上:

  • section1_from_page2 section1_from_page2
  • page1 第1页
  • page3 第3页

Until now, all I'm able to do is to build a new section menu with TypoScript : 到目前为止,我所能做的就是用TypoScript构建一个新的分区菜单:

lib.sectionnavigation = HMENU
lib.sectionnavigation {
    1 = TMENU
    1 {
        sectionIndex = 1
        sectionIndex.type = header
        sectionIndex.useColPos = -1
        NO {
            ATagBeforeWrap = 1
            linkWrap = <span> | </span> <span class="bar"></span>
            allWrap = <li> | </li>
            allWrap.insertData = 1
        }
    }
    special = list
    special.value.data = page:uid
}

And then add this menu in the Main.html partials from bootstrap_package, with f:cObject : 然后,使用f:cObject cObject在bootstrap_package的Main.html部分中添加此菜单:

<f:cObject typoscriptObjectPath="lib.sectionnavigation" />

However, that means that I have to maintain "format" ( <li><span>...</span><span class="bar"></span></li> ) in both the TypoScript and the Main.html partial which is not convenient. 但是,这意味着我必须在TypoScript和Main中都保持“格式”( <li><span>...</span><span class="bar"></span></li>.html不方便。 For example, if I change the menu so that I don't need the bar class span, I'll have to update the partial and the TypoScript! 例如,如果我更改菜单以便不需要条类跨度,则必须更新partial和TypoScript!

From what I've understood, bootstrap_package defines the main menu in setup.txt: 据我了解,bootstrap_package定义了setup.txt中的主菜单:

10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
    levels = 2
    includeSpacer = 1
    as = mainnavigation
}

And then used this in the Main.html partial: 然后在Main.html部分中使用它:

<f:for each="{mainnavigation}" as="mainnavigationItem">

My first plan was to try to built an new array (similar to the one in {mainnavigation} ) using TypoScript but I couldn't find a way! 我的第一个计划是尝试使用TypoScript构建一个新的数组(类似于{mainnavigation}数组),但是我找不到方法! I also tried to use a MenuProcessor but didn't succeed either. 我也尝试使用MenuProcessor,但没有成功。

Any help would be really appreciated! 任何帮助将非常感激!

Thank you. 谢谢。

You should use the possibility to identify the current page in typoscript menus with the option to replace the complete rendering for a menu item. 您应该使用可能性来替换打字菜单中的当前页面,并选择替换菜单项的完整呈现。

The rendering for current page in a menu can be defined with ACT or CUR ( ACT identifies all pages in the root line: current page, parent, grand parent, ...). 菜单中当前页面的呈现可以使用ACTCUR定义( ACT标识根行中的所有页面:当前页面,父页面,祖父页面,...)。 In your case it may not differ, but you might play it safe: 就您而言,它可能没有什么不同,但您可以放心使用:

lib.MainMenu = HMENU
lib.MainMenu {
   wrap = <ul class="nav">|</ul>
   1 = TMENU
   1 {
      NO {
          wrapItemAndSub = <li><span> | </span> <span class="bar"></span></li>
      }
      CUR = 1 
      CUR.doNotShowLink = 1
      // insert your section menu here:  
      CUR.before.cObject < lib.sectionnavigation
   }
}

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

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