TYPO3 - 如何在一个页面上显示英语和德语新闻列表

时间:2018-04-26 09:46:49

标签: listview typo3 tx-news

我有一种多语言语言(One-Tree-Solution),语言为德语(默认)和英语。这个消息用德语和英语。该网站还有一个新闻通讯页面。时事通讯(扩展通讯)写在德语页面上。现在我想自动添加最新的3条新闻到这个时事通讯。我使用以下代码,工作正常:

lib.news = USER
lib.news {
 userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
 extensionName = News
 pluginName = Pi1
 vendorName = GeorgRinger

 switchableControllerActions {
    News {
      1 = list
    }
}

 settings < plugin.tx_news.settings
 settings {
    cropMaxCharacters = 300
    limit = 3
    detailPid = 50
    overrideFlexformSettingsIfEmpty := addToList(detailPid)
    startingpoint = 51
 }
}

这为我提供了默认语言的新闻列表。如何以第二语言添加其他新闻列表?

3 个答案:

答案 0 :(得分:0)

我看到的唯一解决方案是扩展新闻插件。在那里,您可以找到更多资源http://www.lukasjakob.com/extend-a-typo3-extbase-model-with-custom-field/

答案 1 :(得分:0)

根据您的配置,我会想到两个解决方案:

  1. 为每种语言使用不同的文件夹
    如果您对新闻没有严格的翻译,您可以根据不同文件夹中的语言存储新闻。然后可以通过选择不同的存储页面在插件中选择新闻语言

  2. 使用帮助页面
    您可以构建另一个只显示新闻的页面(例如AJAX请求)。 在您的简报(页面)中,您将此页面包含两次:一次使用?L=0,一次使用?L=1

答案 2 :(得分:0)

感谢Bernd和Andrei的建议。我现在找到了另一种解决方案,并通过纯正的打字机插入新闻。这是代码,对我有用:

lib.newsblock = CONTENT
lib.newsblock.wrap = <div class="news"><h2">Letzte Artikel.</h2>|</div>
lib.newsblock {
table = tx_news_domain_model_news
select {
pidInList = {$global.news.pid}
# disable default language selection
languageField = 0
max = 3
where = deleted = 0 and hidden = 0 AND sys_language_uid = 0
orderBy = datetime DESC
}

renderObj = COA   
renderObj {  

10 = TEXT
10.field = title
10.wrap = <h2></h2>

# get news image
20 = FILES
20 {
 references {
  table = tx_news_domain_model_news
  uid.field = uid
  fieldName = fal_media
 }

 begin = 0
 maxItems = 1
 renderObj = IMAGE  
 renderObj.params = class="left" align="left"    
 renderObj {
   wrap = <p>|</p>
   file.import.data =file:current:publicUrl
   file.width = 120c
   file.height = 120c
  }    
}
30 = COA
30.wrap = <div>|</div>
30.10 = TEXT
30.10.field = teaser
30.10.wrap = <p>|</p>
30.20 = TEXT
30.20.value =  &gt; Weiterlesen
30.20.typolink {
parameter = {$global.news.single}
additionalParams.data = field:uid
additionalParams.wrap = &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]=|
useCacheHash = 1
}
30.20.typolink.title.field = title
30.20.wrap = <p>|</p>  
}     
}

lib.news = COA
# default language German
lib.news.10 < lib.newsblock

# English
lib.news.20 < lib.newsblock
lib.news.20.wrap = <div class="news"><h2>Recent articles.</h2>|</div>
lib.news.20.select.where = deleted = 0 and hidden = 0 AND sys_language_uid = 1
lib.news.20.renderObj.30.20.value =  &gt; Read more
lib.news.20.renderObj.30.20.typolink.additionalParams.wrap = &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]=|&L=1