我可以在案例中使用常量吗?

时间:2015-04-24 07:45:27

标签: typo3 typoscript

我有一个依赖id的typoscript菜单。 问题是id是硬编码的,我想改用常量。有可能吗?

以下是运作良好的代码。

lib.navbar {
  10 = HMENU
  10 {
    special = directory
    special.value = {$lib.navbar.main}
    1 = TMENU
    1 {
        noBlur = 1
        expAll = 1
        NO = 1

        NO.wrapItemAndSub.cObject = CASE
        NO.wrapItemAndSub.cObject {
            key.field = uid
            7062 = TEXT
            7062.value = <li class="first_level nav_home">|</li>
            7121 = TEXT
            7121.value = <li id="expositions" class="first_level">|</li>
            7142 = TEXT
            7142.value = <li class="nav_musee first_level">|</li>
            default = TEXT
            default.value = <li class="first_level">|</li>
        }
...

但是我可以使用这样的常量吗?

lib.navbar {
  10 = HMENU
  10 {
    special = directory
    special.value = {$lib.navbar.main}
    1 = TMENU
    1 {
        noBlur = 1
        expAll = 1
        NO = 1

        NO.wrapItemAndSub.cObject = CASE
        NO.wrapItemAndSub.cObject {
            key.field = uid
            {$constant1} = TEXT
            {$constant1}.value = <li class="first_level nav_home">|</li>
            {$constant2} = TEXT
            {$constant2}.value = <li id="expositions" class="first_level">|</li>
            {$constant3} = TEXT
            {$constant3}.value = <li class="nav_musee first_level">|</li>
            default = TEXT
            default.value = <li class="first_level">|</li>
        }
...

2 个答案:

答案 0 :(得分:0)

这是一个导致问题的不同设置。

我刚刚在constants.ts

中定义了这个常量

答案 1 :(得分:0)

您可以尝试的另一种尝试是使用替代而不是案例对象。

像这样:

lib.navbar {
  10 = HMENU
  10 {
    special = directory
    special.value = {$lib.navbar.main}
    1 = TMENU
    1 {
      noBlur = 1
      expAll = 1

      NO = 1
      NO.wrapItemAndSub.cObject = TEXT
      NO.wrapItemAndSub.cObject.value = <li class="first_level">|</li>
      NO.wrapItemAndSub.cObject.value.override = <li class="first_level nav_home">|</li>
      NO.wrapItemAndSub.cObject.value.override.if {
        insertData = 1
        value= {$constant1}
        equals.field = uid
      }
      NO.wrapItemAndSub.cObject.value.override.override = <li id="expositions" class="first_level">|</li>
      NO.wrapItemAndSub.cObject.value.override.override.if {
        insertData = 1
        value= {$constant2}
        equals.field = uid
      }
      NO.wrapItemAndSub.cObject.value.override.override.override = <li class="nav_musee first_level">|</li>
      NO.wrapItemAndSub.cObject.value.override.override.override.if {
        insertData = 1
        value= {$constant3}
        equals.field = uid
      }

我没有测试它,但可以工作。