Search code examples
typo3fieldextendbuildertx-news

Typo3 6.0 - Extending tx_news


I am new in Typo3, and I tried to extend News following this tutorial : http://docs.typo3.org/typo3cms/extensions/news/Main/Tutorial/ExtendingNews/Index.html

My main goal is to create a new extension, which I did using Extension Builder, and then extend News so I can add a new field and use it.

I followed every step described in the tutorial, but there's one point which I'm not sure about how to proceed. Where and how am I supposed to use my new custom field in the template?

In the tutorial, it is written :

"You can now use the new field in the template by using {newsItem.txWorkshopTitle}or {newsItem.workshopTitle}".

Where am I supposed to put this line ? Do I need to make a custom template in my own extension? I don't quite understand.


Solution

  • First, create custom templates by copying the default Fluid templates from EXT:news/Resources/Private/* into a new folder, for example to fileadmin/templates/ext/news/

    Then you need to configure the path to your custom template with TypoScript:

    plugin.tx_news {
        view {
            templateRootPath = fileadmin/templates/ext/news/Templates
            partialRootPath = fileadmin/templates/ext/news/Partials
            layoutRootPath = fileadmin/templates/ext/news/Layouts
            }
    }
    

    Alternatively you can put this stuff into your own extension. Then you'd need some settings like:

    ...
    templateRootPath = EXT:your_ext/Resources/Private/tx_news/Templates
    ...
    

    and put the above mentioned copies into Resources/Private/tx_news/

    Now you can customize the templates in fileadmin/templates/ext/news/ and use your own accessor to it.