基于文本的语言菜单通过Typoscript

时间:2012-12-17 16:22:00

标签: menu internationalization typo3 typoscript

我想点击文本“英语”以获取该网站的英文版本。在我有一个图形菜单之前:

lib.tslangmenu = HMENU
lib.tslangmenu {
  special = language
  special.value = 0,1,2
  addQueryString = 1
  1 = GMENU
  1.NO {
    XY = 24,16
    5 = IMAGE
    5.file = fileadmin/templates/images/deutsch.jpg || fileadmin/templates/images/englisch.jpg || fileadmin/templates/images/kroatisch.jpg
  }

  1.ACT < 1.NO
  1.ACT = 1
  1.ACT.wrap = <span class="langhide"> | </span>

  1.CUR < 1.ACT
  1.CUR = 1
}

到目前为止一直有效。现在我应该将菜单更改为基于文本的菜单。

lib.tslangmenu {
  special = language
  special.value = 0,1,2
  special.normalWhenNoLanguage = 0
  addQueryString = 1
  1 = TMENU
  1.NO = 1
  1.NO.stdWrap.override = Deutsch || English || Hrvatski

  1.ACT < 1.NO
  1.ACT = 1
  1.ACT.stdWrap = <span class="langhide"> | </span>

  1.CUR < 1.ACT
  1.CUR = 1
}

现在完全忽略了span的换行。此外,菜单现在显示如下:

MyCurrentPageName English Hrvatski

如果我在德语中,deutsch这个词会被当前页面标题覆盖。这同样适用于所有其他语言。我也尝试了this blog article中给出的TS。但目前它也是如此。我如何使这个工作?

2 个答案:

答案 0 :(得分:3)

第一个错误在你的包装中:NO没有被包装,所以没有生成跨度(对于NO-items)。显示页面标题的问题来自错误的复制。这条线

1.ACT < 1.NO

应该是

1.ACT < .1.NO

以防万一,这是我正在使用的TS-config:

lib.languageMenu = HMENU
lib.languageMenu {
  special = language
  special.value = 0,1

  1 = TMENU
  1 {
    wrap = <ul class="langMenu">|</ul>
    noBlur = 1
    NO = 1
    NO {
      linkWrap = <li class="menu-item normal">|</li>

      stdWrap.override = English || Deutsch
      stdWrap.htmlSpecialChars = 1
    }

    ACT < .NO
    ACT {
      doNotLinkIt = 1
      linkWrap = <li class="menu-item active">|</li>
    }

    # NO + Translation doesn't exist
    USERDEF1 < .NO
    USERDEF1.doNotLinkIt = 1

    # ACT + Translation doesn't exist
    USERDEF2 < .ACT
    USERDEF2.doNotLinkIt = 1
  }
}

的问候,
斯特

答案 1 :(得分:1)

使用旗帜图标

查看此处
lib.languageMenu = HMENU
lib.languageMenu{

     special = language
     special.value = 0,1
     protectLvar = 1
     special.normalWhenNoLanguage = 0
    # wrap = <div class="language"><ul>|</ul></div>
     1 = TMENU
     1 {
       NO = 1
       NO {


        # linkWrap = <li class="in-active">|</li> || <li class="in-active">|</li>
         stdWrap.override = {$germanLabel}<img alt="" src="typo3conf/ext/website_lctech/Resources/Public/images/german.png">|| {$englishLabel}<img alt="" src="typo3conf/ext/website_lctech/Resources/Public/images/english.png">
         doNotLinkIt = 1
         stdWrap.typolink.parameter.data = page:uid
         stdWrap.typolink.additionalParams = &L=0 || &L=1
         stdWrap.typolink.addQueryString = 1
         stdWrap.typolink.ATagParams =class="InActive"
         stdWrap.typolink.addQueryString.exclude = id,cHash,no_cache
         stdWrap.typolink.addQueryString.method = GET
         stdWrap.typolink.useCacheHash = 0
         stdWrap.typolink.no_cache = 0
         stdWrap.htmlSpecialChars = 0

#         normalWhenNoLanguage = 0
       }
       ACT = 1
       ACT < .NO
       ACT.stdWrap.typolink.ATagParams =class="Active"
       ACT.stdWrap.htmlSpecialChars = 0



     #  USERDEF1 < .NO
     #  USERDEF1.doNotLinkIt = 0
    }
}