Adrian
Adrian

Reputation: 1002

How to chose the tx_news list template using TypoScript

I'm starting my "adventure" with tx_news TYPO3 extension. I created the new list template and I see it in flexform on drop down list - that is ok, but how to chose that template using only TypoScript? Is it possible?

Thanks for any help.

Upvotes: 0

Views: 2154

Answers (3)

Oleg V Karun
Oleg V Karun

Reputation: 736

Just 3 Steps.

1) Copy tepmlate from EXT folder to web site template and add in typoscript

plugin.tx_news {
    view {
        # Additional template paths
        templateRootPaths.110 = youPath/Templates/
        # Additional partial paths
        partialRootPaths.110 = youPath/Partials/
        # Different template for pagination
        widget.Tx_News_ViewHelpers_Widget_PaginateViewHelper.templateRootPath = youPath/Templates/
    }
}

2) Copy Partials inside your new "news" template. Like copy Partial/List to Partials/Latest (for exampl) 3) Now you shood write rule fore template "youPath/Templates/List.html" or/and the same fore Detail.html (if need)

<!-- Strat template -->
<f:section name="content">

    <f:if condition="{settings.templateLayout}"> <!-- if we heve Layout than include our new partitial -->

        <f:then>

            <f:render partial="{settings.templateLayout}/List" arguments="{news: news, settings:settings}"/>

        </f:then>

        <f:else>
<!-- ... default Template-->

That's all) Good luck

Upvotes: 1

Manuel Thaler
Manuel Thaler

Reputation: 126

I do get following Error when using your script.

No value found for key "TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper->switchExpression", thus the key cannot be removed.

I've checked the manual as well (http://docs.typo3.org/typo3cms/extensions/news/Main/Tutorial/IntegrationWithTs/Index.html) and also this snipped seems not to work properly.

This possibly might fix the issue: https://forge.typo3.org/issues/59255

Upvotes: 0

Adrian
Adrian

Reputation: 1002

I figured out. Here is the solution - if you have in your template, the templateLayout with number 99 (as in tx_news tutorial) <f:if condition="{settings.templateLayout} == 99"> in TypoScript you should use this code to call the 99 layout:

lib.some_news < lib.news
lib.some_news = USER
lib.some_news {
userFunc = tx_extbase_core_bootstrap->run
extensionName = News
pluginName = Pi1

switchableControllerActions.News.1 = list

settings < plugin.tx_news.settings
settings {
  categories = 7
  templateLayout = 99 # your layout number
  limit = 1
  detailPid = 22
  overrideFlexformSettingsIfEmpty := addToList(detailPid)
  startingpoint = 20
  list {
    media {
      image {
        maxWidth = 588
        maxHeight = 428
        width = 588c
        height = 428c
      }
    }
  }
 }
} 

Upvotes: 1

Related Questions