mario
mario

Reputation: 624

TYPO3, News. How do I define a new list view?

I need a rush course on News (and some TYPO3). I would like to have a further 'what to display' plugin option, to show a customized list of news.

I (believe to) understand how to define a new mylistAction method within class newsController, and a corresponding mylist.html template.

What I miss is how I get a (working) mylist option within the BE module to insert the plugin into a page. I am not sure what else I need to update and how (TCA, language files, TS, ... )

Thanks for your help, Cheers, mario

----- EDIT and SOLVED I made it!

Now i am able to insert a News plugin into a page with the
new listm option, and the listm template is rendered. (It seems I needed to trash cache too). Good!

Upvotes: 0

Views: 1365

Answers (2)

Jost
Jost

Reputation: 5840

It's a bad idea to modify the news extension - you can't really update it afterwards.

However, EXT:news has a built in way to add multiple list views, documented here.

Short version: There is a template selector in the news plugin, and you can add items to it through TypoScript. Put something like this in your pageTS:

tx_news.templateLayouts {
    1 = A custom layout
    99 = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.mode.news_listm
}

The choice you make in the backend in this field is passed to the views in the variable settings.templateLayout.

So in your List.html template file you can do this:

<f:if condition="{settings.templateLayout} == 99">
    <f:then>
        <!-- Render template with number 99 here -->
    </f:then>
    <f:else>
        <!-- Render template with number 1 here -->
    </f:else>
</f:if>

If you have multiple templates, it would be a good idea to use the switch/case-ViewHelpers from EXT:vhs or something similar.

Upvotes: 2

Respant
Respant

Reputation: 198

If you want to insert the plugin into a page you need create custom frontend plugin for it. Something like

ext_tables.php:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    'Namespace.' . $_EXTKEY,
    'custom_news',
    'Custom News'
);

ext_localconf.php:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'Namespace.' . $_EXTKEY,
    'custom_news',
    array('CustomNews' => 'mylist'),
    // non-cacheable actions
    array('CustomNews' => 'mylist')
);

I hope you created custom extension for it and extended newsController.

Regards, Anton

Upvotes: 0

Related Questions