Search code examples
phptypo3tx-news

TYPO3 add and implement action for news extension


In my Configuration\TCA\Overrides\tx_news_domain_model.php I add option to select field like this:

$GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['switchableControllerActions']['newItems']['News->gallery'] = 'Gallery view';

In my ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['classes']['Controller/NewsController'][] = 'news_extender';

In my extension

namespace Vendor\NewsExtender\Controller\NewsController;

class NewsController extends \GeorgRinger\News\Controller\NewsContoller {

    public function galleryAction()
    {
    ...
    }
}

I get an error: An action "galleryAction" does not exist in controller "GeorgRinger\News\Controller\NewsController" So my guess is no override of actual NewsController happens. My question is if it is possible to add new action to the controller the way I do (['Controller/NewsController'][])? If not, can I achieve this other way? If so provide an example.


Solution

  • I don't know what exactly i did to fix it, but as i did my research i found out that my path to controller was wrong, after changing it i spend few more hours clearing cache from BE and reinstalling extension with no result. After adding line function listAction() {} to my NewsController i finally got an error Fatal error: Cannot redeclare GeorgRinger\News\Controller\NewsController::listAction() in D:\live_system\typo3\typo3_src\typo3temp\Cache\Code\news\tx_news_controller_newscontroller.php on line 618. After clearing Typo3temp/Cache manually again and removing listActionfrom my controller all works just fine.