0
votes

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!

  • i defined action listmAction() within NewsController.php
  • i defined template listm.html
  • within Configuration/Flexforms/flexform_news.xml i added lines:

    <numIndex index="22">
    <numIndex index="0">LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.mode.news_listm
    </numIndex>
    <numIndex index="1">News->listm</numIndex>
    </numIndex>
  • within locallang_be.xlf i added lines

    <trans-unit id="flexforms_general.mode.news_listm" xml:space="preserve">
    <source>List m view</source>
    </trans-unit> 

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!

2

2 Answers

2
votes

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.

0
votes

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