TYPO3:添加特殊菜单 CE 并添加 class="active"; [英] TYPO3: Add special menu CE and add class="active"

查看:29
本文介绍了TYPO3:添加特殊菜单 CE 并添加 class="active";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TYPO3中可以插入一个特殊菜单作为内容元素,可以选择大约八个收集菜单的不同方式.

In TYPO3 one can insert a special menu as a content element, you can select about eight different ways to collect the menu.

在我选择的菜单中,如果菜单项处于活动状态,则没有分配类,我需要用 CSS 突出显示它.我想知道如何添加自定义菜单.

In the menu I selected there is no class assigned if the menu item is active, and I need to highlight it with CSS. And I'd like to know how to add a custom menu.

注意:一旦我确实应用了我自己的答案中提供的解决方案,我意识到主要困难是(通常在 TYPO3 中)缓存,请注意经常刷新,否则您永远无法确定什么是正确的代码和什么不是...

Note: Once I did apply the solution supplied in my own answer I realized that the main difficulty was (and generally is in TYPO3) the caching, be aware to refresh frequently otherwise you'll never be sure what is correct code and what isn't...

推荐答案

答案:

  1. 复制原始流体模板(在我的例子中是所选页面的子页面菜单):

  1. Copy the original fluid template (menu of subpages of selected pages in my case):

typo3/sysext/fluid_styled_content/Resources/Private/Partials/Menu/Type-1.html

TYPO3 v8:不同的路径和不同的名称

TYPO3 v8: different path and different names

typo3/sysext/fluid_styled_content/Resources/Private/Templates/xxx.html

到(与您将在第 4 点中声明的目录一致)

To (coherently to the directory you'll declare in point 4)

EXT:myExtension/Resources/Private/Partials/Menu/Type-1.html

  • 在您的设置中添加一个提供当前页面 ID 的变量(libs.ts,可能这可以更容易地完成,并且该值可能已经存在以供第 3 点使用,但我不知道如何代码).

  • Add a variable that gives the current page id in your setup (libs.ts, probably this can be done easier and this value could be present already for use in point 3, but I wouldn't know how to code that).

    lib.pageId = TEXT
    lib.pageId.data = page:uid
    

  • 编辑模板(我这里只给出适用条件)

  • Edit the template (I just give the applicable condition here)

    <f:if condition="{page.uid} == {f:cObject(typoscriptObjectPath: 'lib.pageId')}">
        ...
    </f:if>
    

  • 包括新的流体模板(我覆盖了原来的模板,保留原来的名字)

  • Include the new fluid template (I overwrite the original one, keeping the original name)

    TYPO3 v8:使用 lib.contentElement 而不是 lib.fluidContent

    lib.fluidContent.partialRootPaths.1920 = EXT:myExtension/Resources/Private/Partials/Menu/
    

    或者像我一样,将它包含在您的页面设置中

    Or as I did, include it in your page-setup

    page = PAGE
    page {
        # Page Main template
        10 = FLUIDTEMPLATE
        10 {
            partialRootPaths = EXT:myExtension/Resources/Private/Partials/Menu/
        }
    }
    

  • 如果您想将其作为选项添加到列表中,请重新编号文件(如 Type-9.html)并将其添加到页面 TSConfig 的菜单中:

  • If you'd like to add it as an option to the list you re-number the file (like Type-9.html) and add it to the menu in Page TSConfig:

    TYPO3 v8:我没有找到在 v8 中添加菜单的方法,这里给出的配置不起作用......

    TYPO3 v8: i did not find a way to add a menu in v8, the config given here does not work ...

    TCEFORM.tt_content.menu_type {
       types {
          menu{
             addItems {
                9 = menu of subpages of selected pages active highlighted
             }
          }
       }
    }
    

  • 这篇关于TYPO3:添加特殊菜单 CE 并添加 class="active";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆