简体   繁体   中英

TYPO3 tt_news detail with language switch

I've got a problem with tt_news in TYPO3.

If I am on a detail page, there is a url with a few get variables. If I switch the page language on the site, I lose the correct url.

Can anybody help me to configure the tt_news. I'd like to stand at the same detail page with the difference that the content ist in the other language?

If you post your TypoScript to create your language-switch, it would be easiert to help.

But the main prinziple would be:

  # change the links you have defined, to add the QueryString Parameters
  # so it will work with other extensions too
  ...typolink.addQueryString = 1
  ...typolink.addQueryString.methode = G

If you want to define explicit which params should be used:

  # of define on your own which parameters should be added:
  ...typolink.additionalParams.append = COA
  ...typolink.additionalParams.append {
     10 = TEXT
     10.data = GP:tt_news[uid]
     10.required = 1
     # sanitize your url
     10.rawUrlEncode = 1
     10.wrap = &tt_news[uid]=|

     # and so on
     20 = TEXT

  }

If you do not want duplicate parameters:

  # check for duplicate parameters
  config.uniqueLinkVars = 1

I had exactly the same problem a view years ago and figured out the following snippet:

lib.logo = TEXT
lib.logo {
    typolink {
        parameter.data = TSFE:id
        returnLast = url

        addQueryString = 1
        addQueryString {
            method = GET
            exclude = cHash, no_cache, id, FE_SESSION_KEY, L
        }

        additionalParams = &L=1
    }
}

The link, generated by this code, contains all GET variables (thanks to addQueryString ) excepted by:

  • cHash (used for caching)
  • no_cache (force to disable the cache)
  • id (id of the current page that we want to set)
  • FE_SESSION_KEY (is used on cross-domain-linkings to keep the session)
  • L (the id of the language-record)

An example for language switch and tx_news, based upon the answer of maholz:

lib.langNavi = HMENU
lib.langNavi {
  special = language
  special.value = 0,1
  1 = TMENU
  1 {

        NO = 1
        NO.allWrap = |*| |  |   |*| |
        NO.linkWrap = |
        NO.stdWrap.setCurrent = Deutsch || English
        NO.stdWrap.current = 1
        NO.additionalParams {
            append = COA
            append {
                10 = TEXT
                10.data = GP:tx_news_pi1|news
                10.required = 1
                # sanitize your url
                10.rawUrlEncode = 1
                10.wrap = &tx_news_pi1[news]=|
            }
        }

        # Current language selected:
        ACT < .NO
        ACT.linkWrap = <strong> | </strong>

        # Language that is NOT available:
        USERDEF1 < .NO
        USERDEF1.linkWrap = <span class="text-muted"> | </span>
        USERDEF1.doNotLinkIt = 1

  }
}

Go ahhad with this. Just pay attantion in TYPO3 v4 GPvar: but in TYPO3 v6 GP :

####### LANGUAGE SELECTOR #######
lib.langMneu = HMENU
lib.langMneu.30 {  
      wrap = <ul class="lang"> | </ul></div>
      special = language
      special.value = 0,1,2
      special.normalWhenNoLanguage = 0
      1 = TMENU
      1 {
      noBlur = 1
      NO = 1
      NO {
        additionalParams.cObject = COA
        additionalParams.cObject {
          5 = TEXT
          5.wrap = &L=1

          10 = TEXT
          10.data = GP : tx_ttnews | backPid
          10.wrap = &tx_ttnews[backPid]=|
          10.required = 1

          20 = TEXT
          20.data = GP : tx_ttnews | tt_news
          20.wrap = &tx_ttnews[tt_news]=|
          20.required = 1

          30 = TEXT
          30.data = GP : cHash
          30.wrap = &cHash=|
          30.required = 1        
        }
      linkWrap = <li class="eng">|</li>||<li class="de">|</li>||<li class="ru">|</li>
      stdWrap.override = Eng||De||Rus
      doNotLinkIt = 0


      stdWrap.typolink.additionalParams = &L=0||&L=1||&L=3
      stdWrap.typolink.addQueryString = 1
      stdWrap.typolink.addQueryString.exclude = L,id,cHash,no_cache
      stdWrap.typolink.addQueryString.method = GET 
      stdWrap.typolink.useCacheHash = 1
      stdWrap.typolink.no_cache = 0
    }
      # Active
      ACT = 0
      ACT <.NO
      ACT.linkWrap = <li class="current eng">|</li>||<li class="current de">|</li>||<li class="current ru">|</li>
      #ACT.ATagParams = class="cur"
      #USERDEF1 <.NO
      #USERDEF2 < .ACT
      }
    }
####### END LANGUAGE SELECTOR #######

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM