简体   繁体   中英

TYPO3: RealURL Language Switch for Extbase Extension

I have set up a single-domain website with different languages and configured RealURL.

On one page, there is a FE plugin with list and show actions. The links from the list to the show action are rendered correctly, for example:

en/press.html -> en/press/release1.html
en/press.html -> en/press/release2.html

Clicking on one of the links surfaces the detail page - so far, so good. Everything works as expected.

However, the language switch returns the following links (on the detail page):

en/press.html
de/presse.html

The links, of course, should read as follows:

en/press/release1.html
de/presse/aussendung1.html

Also, the breadcrumb menu does not show the detail page; it reads Home > Press , regardless of whether I'm on the list or show action.

Language Nav

temp.langNav = COA
temp.langNav {
  10 = HMENU
  10 {
    special = language
    special.value = 0,1,2,3,4,5,6,7,8
    special.normalWhenNoLanguage = 0
    wrap = <ul class="lang-sel__list">|</ul>
    1 = TMENU
    1 {
      noBlur = 1
      NO = 1
      NO {
        allWrap = <li class="lang-sel__item">|</li>
        ATagParams = class="lang-sel__link"
        stdWrap.setCurrent = English || Deutsch || Русский || Česky || Polski || Français || Română || Hrvatski || Slovenčina
        stdWrap.current = 1
      }

      USERDEF1 = 1
      USERDEF1 {
        doNotLinkIt = 1
        stdWrap.cObject = TEXT
        stdWrap.cObject.value =
      }
    }
  }
}

temp.selectedLang = TEXT
temp.selectedLang.value < config.language

Breadcrumb Nav

temp.breadcrumbNav=COA
temp.breadcrumbNav {
10 = HMENU
10 {
 special = rootline
 special.range = 0|-1
 includeNotInMenu = 1
 wrap = |
 1 = TMENU
     1.noBlur = 1
     1.CUR = 1
     1.wrap = |
     1.NO {
         stdWrap.field = title
         ATagParams = class="main-header__breadcrumb-link"
         ATagTitle.field = nav_title // title
         linkWrap = <li class="main-header__breadcrumb-item">|</li>
     }
     1.CUR {
         stdWrap.field = title
         linkWrap = <li class="main-header__breadcrumb-item">|</li>
         doNotLinkIt = 1
         }
    }
}

RealURL Config

$TYPO3_CONF_VARS['FE']['addRootLineFields'].= ',tx_realurl_pathsegment';

$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
    '_DEFAULT' => array(
        'init' => array(
            'enableCHashCache' => 1,
            'appendMissingSlash' => 'ifNotFile',
            'enableUrlDecodeCache' => 1,
            'enableUrlEncodeCache' => 1,
            'postVarSet_failureMode' => '',
        ),
        'redirects' => array(),
        'preVars' => array(
            array(
                'GETvar' => 'L',
                'valueMap' => array(
                    'en' => 0,
                    'de' => 1,
                    'ru' => 2,
                    'cz' => 3,
                    'pl' => 4,
                    'fr' => 5,
                    'ro' => 6,
                    'hr' => 7,
                    'sk' => 8
                ),
                'valueDefault' => 'en',
            ),
        ),
        'pagePath' => array(
            'type' => 'user',
            'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'expireDays' => 7,
            'rootpage_id' => 1,
            'firstHitPathCache' => 1,
        ),
        'fixedPostVars' => array(
            '_DEFAULT' => array(
                array(
                    'GETvar' => 'press',
                    'lookUpTable' => array(
                        'table' => 'tx_myext_domain_model_press',
                        'id_field' => 'uid',
                        'alias_field' => 'title',
                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => 1,
                        'useUniqueCache_conf' => array(
                            'strtolower' => 1,
                            'spaceCharacter' => '-'
                        ),
                        'languageGetVar' => 'L',
                        'languageField' => 'sys_language_uid',
                        'transOrigPointerField' => 'l10n_parent',
                    )
            )
        ),
        'fileName' => array(
            'defaultToHTMLsuffixOnPrev' => 1
        ),
    ),
);

You need to tell TYPO3 to keep the parameters.

This is done by configuring addQueryString in the HMENU ConentObject. Your example would be extended by:

temp.breadcrumbNav=COA
temp.breadcrumbNav {
    10 = HMENU
    10 {
        1 {
            NO {
                addQueryString.exclude = L,cHash
            }
        }
    }
}

For further information check the documentation:

docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Hmenu/Index.html and docs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink/Index.html

And the solution above can be found on forge: https://forge.typo3.org/issues/16466#note-3

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