testing
testing

Reputation: 20279

text based language menu via Typoscript

I want to click on the text "English" to get the english version of the website. Before I had a graphical menu:

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
}

This worked so far. Now I should change the menu to a text-based menu.

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
}

Now the wrap with the span is completely ignored. Also the menu is now displayed as follows:

MyCurrentPageName English Hrvatski

If I'm on german the word deutsch is overwritten with the current page title. The same is valid for all other languages. I also tried the TS given in this blog article. But currently it does the same. How do I get this working?

Upvotes: 2

Views: 2117

Answers (2)

Bharat Parmar
Bharat Parmar

Reputation: 1880

Check Here with flag icon

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
    }
}

Upvotes: 1

Jost
Jost

Reputation: 5840

The first error is in your wrap: NO is not wrapped, so no span is generated (for NO-items). The problem that the page title is shown comes from wrong copying. The line

1.ACT < 1.NO

should really be

1.ACT < .1.NO

Just in case, here is a TS-config I have in active use:

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
  }
}

Regards,
Jost

Upvotes: 3

Related Questions