简体   繁体   English

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

[英]TYPO3 - How to show English and German news list on one page

I have a multilingual language (One-Tree-Solution) with the languages German (default) and English. 我有一种多语言的语言(一棵树解决方案),其中包含德语(默认)和英语。 The news are in German and English. 该新闻有德文和英文。 The website also has a newsletter page. 该网站还有新闻通讯页面。 The newsletter (Extension newsletter) is written on the German page. 新闻简讯(扩展新闻简讯)写在德语页面上。 Now I want to add automatically the last 3 news to this newsletter. 现在,我想将最后3条新闻自动添加到此新闻通讯中。 I use the following code, which works fine: 我使用以下代码,效果很好:

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

This gives me a list of the news in the default language. 这为我提供了默认语言的新闻列表。 How can I add an additional list of the news in the second language as well? 我如何也可以用第二种语言添加新闻的其他列表?

depending on your configuration two solutions come to mind: 根据您的配置,可以想到两种解决方案:

  1. use different folders for each language 每种语言使用不同的文件夹
    if you have no strict translation for the news, you can store the news depending on language in different folders. 如果您对新闻没有严格的翻译,则可以根据语言将新闻存储在不同的文件夹中。 then the language of news can be selected in the plugin by selecting different storage pages 然后可以通过选择不同的存储页面在插件中选择新闻的语言

  2. use a help-page 使用帮助页面
    you can build another page where you show only the news (like for an AJAX request). 您可以建立另一个仅显示新闻的页面(例如AJAX请求)。 in your newsletter (page) you include this page twice: once with ?L=0 and once with ?L=1 在您的新闻通讯(页面)中,您两次包含此页面:一次带有?L=0 ,一次带有?L=1

The only solution i see there is to extend the news plugin. 我看到的唯一解决方案是扩展新闻插件。 There you can find more resources http://www.lukasjakob.com/extend-a-typo3-extbase-model-with-custom-field/ 在那里您可以找到更多资源http://www.lukasjakob.com/extend-a-typo3-extbase-model-with-custom-field/

Thank you Bernd and Andrei for your suggestions. 感谢Bernd和Andrei的建议。 I now found another solution and inserted the news by pure typoscript. 现在,我找到了另一种解决方案,并通过纯错字插入了新闻。 This is the code, which works for me: 这是对我有用的代码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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