TYPO3 fluid v:page.languageMenu and tx_news



当我需要语言切换器时,我通常像这样使用TypoScrct。

lib.langnav >
lib.langnav = HMENU
lib.langnav {   
  wrap = <ul>|ul
  special = language
  special.value = 0,1,3
  special.normalWhenNoLanguage = 0
    1 = TMENU
    1 {
    noBlur = 1
    NO = 1
    NO {
      additionalParams.cObject = COA
      additionalParams.cObject {
      5 = TEXT
      5.wrap = &L=1

然后我添加tx_news控制器和操作来获取详细信息页面上新闻项的翻译 url:

  10 = TEXT
  10.data = GP:tx_news_pi1|news
  10.wrap = &tx_news_pi1[news]=|
  10.required = 1
  20 = TEXT
  20.data = GP:tx_news_pi1|controller
  20.wrap = &tx_news_pi1[controller]=|
  20.required = 1
  30 = TEXT
  30.data = GP:tx_news_pi1|action
  30.wrap = &tx_news_pi1[action]=|
  30.required = 1

。和其他标准的东西。

现在,当我与FLUID合作时,我有:

    <v:page.languageMenu class="language-menu"
                         defaultIsoFlag="{settings.config.defaultIsoFlag}"
                         defaultLanguageLabel="{settings.config.defaultLanguageLabel}"
                         tagName="ul"
                         tagNameChildren="li"
                         linkCurrent="0"
                         as="languageMenu"
                         hideNotTranslated="1"
                         classCurrent="'current'"> ... </v:page.languageMenu>

如何在流畅lang.menu中添加tx_news控制器和操作(为新闻详情页制作翻译网址)?

我只找到一个解决方案 - 覆盖默认的视图助手以在 url 中添加查询字符串。在我的扩展(流体主题)typo3conf/ext/huskytheme/Classes/ViewHelpers/Page/LanguageMenuViewHelper中.php

<?php
namespace HITHuskythemeViewHelpersPage;

class LanguageMenuViewHelper extends FluidTYPO3VhsViewHelpersPageLanguageMenuViewHelper {
        protected function getLanguageUrl($uid) {
        $excludedVars = trim((string) $this->arguments['excludeQueryVars']);
        $config = array(
            'parameter' => $this->getPageUid(),
            'returnLast' => 'url',
            'additionalParams' => '&L=' . $uid,
            'useCacheHash' => $this->arguments['useCHash'],
            'addQueryString' => true,
            'addQueryString.' => array(
                                'method' => 'GET',
                'exclude' => 'id,L,cHash' . ($excludedVars ? ',' . $excludedVars : '')
            )
        );
        if (TRUE === is_array($this->arguments['configuration'])) {
            $config = $this->mergeArrays($config, $this->arguments['configuration']);
        }
        return $this->cObj->typoLink('', $config);
    }
}

和模板

{namespace hit=HITHuskythemeViewHelpers}
...
<f:section name="LanguageMenu">
    {v:variable.typoscript(path: 'plugin.tx_huskytheme.settings') -> v:variable.set(name: 'settings' )}
    <v:variable.set name="currentlang" value="{v:page.language(normalWhenNoLanguage: 0)}" />
    <div class="lang  pull-right"> 
        <hit:page.languageMenu 
            defaultLanguageLabel="{settings.config.defaultLanguageLabel}"
            linkCurrent="0"
            as="languageMenu"
            hideNotTranslated="1"
            classCurrent="'current'"
            >
            <v:variable.set name="langcount" value="{languageMenu -> f:count()}" />
            <f:if condition="{langcount > 1}">
                <f:then>
                    <ul class="navlang">
                        <f:for each="{languageMenu}" as="item" iteration="iteration">
                            <f:if condition="{item.current}">
                                <f:then>
                                    <li class="active">
                                        <span>{item.label}</span>
                                    </li>
                                </f:then>
                                <f:else>
                                    <li class="{f:if(condition: iteration.isLast, then: 'last')}">
                                        <a href="{item.url}">{item.label}</a>
                                    </li>
                                </f:else>
                            </f:if>
                        </f:for>
                    </ul>  
                </f:then>
            </f:if>
            </hit:page.languageMenu>
    </div>
</f:section>

相关内容

  • 没有找到相关文章

最新更新