typo3、typoscript、TMENU/HMEN:当前项目之后项目的特殊格式
有什么方法可以在当前项目之后立即为菜单项应用特殊格式, 即 CUR + 1。类似这样的内容:
lib.menu = HMENU
lib.menu {
1 = TMENU {
NO = 1
NO = {
...
}
...
# The currently selected item
CUR = 1
CUR {
allWrap = ...
}
# The next item
CUR + 1 = 1
CUR + 1 {
allWrap = ...
}
}
}
如果您有任何反馈,我将不胜感激。还有替代方案:可以编写 PHP 类/函数,而不是用打字稿编写。
It there any way to apply special formatting for the menu item immediately after the current item,
that is CUR + 1. Something like:
lib.menu = HMENU
lib.menu {
1 = TMENU {
NO = 1
NO = {
...
}
...
# The currently selected item
CUR = 1
CUR {
allWrap = ...
}
# The next item
CUR + 1 = 1
CUR + 1 {
allWrap = ...
}
}
}
I would appreciate any feedback you might have. Also alternatives: Can write a PHP class/function instead of writing this in typoscript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,仅使用 TypoScript 这是不可能的。我也没有真正看到 PHP 的好的解决方案。不过,您可以使用 PHP 来完成此操作,但您需要加载与 PHP 中的菜单本身相同的菜单项。这使得它非常低效并且根本不灵活。
我会说向链接或换行添加一个特殊的类属性,并使用 JavaScript 执行格式化。活动项之后的项被修改。
Unfortunately this is not possible with just TypoScript. I don't really see a good solution with PHP really either. You could however do it with PHP, but you will need to load the same menu items like in your menu itself inside PHP. Which makes it very inefficient and not flexible at all.
I would say add a special class attribute to the link or wrap and perform your formatting with JavaScript. Where the item coming after the active one is modified.
所以我设法自己解决这个问题。答案是使用所谓的寄存器来标记我们是否已经传递了当前对象。例如:
使用 LOAD_REGISTER 设置的寄存器基本上是一种运行时变量,可以在迭代菜单项(或其他内容)的过程中设置和重置。因此,它可用于记录菜单项的进度,特别是记录我们是否已通过当前菜单项 (CUR)。
rant begin 考虑到打字稿是特定于领域的语言,主要用于菜单等规范化内容,这很难说是一个优雅的解决方案。/rant end
So I manage to solve this myself. The answers is to use a so-called register to mark if we've passed the current object or not. For example:
A register, set using LOAD_REGISTER, is basically a type of run-time variable, which can be set and reset in the course of iterating through the menu items (or whatever). As such it can be used to note our progress through the menu items, particularly noting if we've passed the current menu item (CUR) or not.
rant begin Hardly an elegant solution considering that typoscript is domain-specific language which is mainly used for this normatting stuff like menus./rant end