typo3、typoscript、TMENU/HMEN:当前项目之后项目的特殊格式

发布于 2024-12-11 22:37:24 字数 459 浏览 1 评论 0原文

有什么方法可以在当前项目之后立即为菜单项应用特殊格式, 即 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事和酒 2024-12-18 22:37:25

不幸的是,仅使用 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.

梦里的微风 2024-12-18 22:37:25

所以我设法自己解决这个问题。答案是使用所谓的寄存器来标记我们是否已经传递了当前对象。例如:

lib.menu = HMENU
lib.menu {
    1 = TMENU {
        NO = 1
        NO = {
            # Render using Common Object Array (COA)
            stdWrap.cObject = COA
            stdWrap.cObject {
                # Normal Case (However the an item should normally be rendered
                10 = TEXT
                10 {
                   if {
                       isTrue.data = register:cid
                       value = NORMAL RENDERING
                   }
                }
                20 = TEXT
                20 {
                   if {
                       isTrue.data = register:data
                       value = RENDERING (IMMEDIATELY) AFTER THE CURRENT ITEM
                   }
                }
                # Unset the register (after we've done with our special formatting)
                30 = LOAD_REGISTER
                30.cid= 0
            }
        }
        ...
        # The currently selected item
        CUR = 1
        CUR {
            # Render using Common Object Array (COA)
            stdWrap.cObject = COA
            stdWrap.cObject {
              # However the Current item should normally be rendered
              10 = TEXT
              10.field = title
              # Mark that we've reached the current item
              20 = LOAD_REGISTER
              20.cid= 1
            }    
        }     
    }
}

使用 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:

lib.menu = HMENU
lib.menu {
    1 = TMENU {
        NO = 1
        NO = {
            # Render using Common Object Array (COA)
            stdWrap.cObject = COA
            stdWrap.cObject {
                # Normal Case (However the an item should normally be rendered
                10 = TEXT
                10 {
                   if {
                       isTrue.data = register:cid
                       value = NORMAL RENDERING
                   }
                }
                20 = TEXT
                20 {
                   if {
                       isTrue.data = register:data
                       value = RENDERING (IMMEDIATELY) AFTER THE CURRENT ITEM
                   }
                }
                # Unset the register (after we've done with our special formatting)
                30 = LOAD_REGISTER
                30.cid= 0
            }
        }
        ...
        # The currently selected item
        CUR = 1
        CUR {
            # Render using Common Object Array (COA)
            stdWrap.cObject = COA
            stdWrap.cObject {
              # However the Current item should normally be rendered
              10 = TEXT
              10.field = title
              # Mark that we've reached the current item
              20 = LOAD_REGISTER
              20.cid= 1
            }    
        }     
    }
}

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文