首页 > 解决方案 > Give a class to specific Page in Main Menu in Typo3

问题描述

I want to achieve having a menu with 2 levels, and some should always be expanded - some shouldn't. Is there any way I can hand over a class or something, if possible set up in the backend, to be able to choose which menu links should be expanded?

For example:

  1. Menu Link 1 with no subitems
  2. Menu Link 2 with subitems expandable (sublinks only visible on click)
  3. Menu Link 3 with subitems always expanded (sublinks always visible)
    • Sub link 1
    • Sub link 2

标签: typo3typo3-9.x

解决方案


通常,您需要向链接或li标签添加一个类,以便 CSS 或 javascript 可以决定哪些部分是可见的。

一个类似的问题是根本不呈现某些子菜单,但是由于您希望这些子菜单在单击时可见,因此无论如何都必须呈现它们。所以这只是如何将这些信息放入渲染菜单的问题。它应该是一个可以改变可见性的标志。这可以用 CSS 和 javascript 来完成。

您可以在记录中存储此信息,pages您可以在其中使用任何其他未使用的字段(例如layout)。实现取决于您生成菜单的方式。

同时,您有两种选择:

  1. 经典:带排版
  2. 流体:菜单处理器

使用这两个选项,您可以将类添加到 JS 可以处理的菜单项。


推荐阅读