I try to extend the NewsController to add some more infos to the detailAction. So far I have this code working:

<?php

/**
 * Controller to extend the News Controller
 *
 * @package template_my
 * 
 */
class Tx_TemplateMy_Controller_NewsControllerExtended extends Tx_News_Controller_NewsController {

        /**
     * Single view of a news record
     *
     * @param Tx_News_Domain_Model_News $news news item
     * @param integer $currentPage current page for optional pagination
     * @return void
     */
    public function detailAction(Tx_News_Domain_Model_News $news = NULL, $currentPage = 1) {
        parent::detailAction($news, $currentPage);
        $this->view->assign("test", "test");
    }


}

I overwrite it with typoscript:

#Extend News Controller
config.tx_extbase {
    objects {
        Tx_News_Controller_NewsController {
            className = Tx_TemplatePMy_Controller_NewsControllerExtended
        }
    }
}

I can access the {test} variable in the Detail.html. But I get another problem now: In the Detail.html I create Links to tags and they dont work anymore:

<f:for each="{newsItem.tags}" as="tag">
                        <div>
                        <f:link.page pageUid="357" additionalParams="{tx_news_pi1:{overwriteDemand:{tags: tag}}}"> 
                            {tag.title} 
                        </f:link.page> 
                        </div>
                    </f:for>

Error:

    Exception while property mapping at property path "":It is not allowed to map property "tags".
 You need to use $propertyMappingConfiguration->allowProperties('tags') to enable mapping of this property

I tried to add $propertyMappingConfiguration->allowProperties('tags') into the code but it does not help, and I also don't know why this error comes.

What I want to achieve: have all newsItem with the same Tag as the current newsItem in the Detail.html (Cause I need to show information - like the title, picture, short description - of all the newsItem with the same tag in the detailview). For that I want to assign the newsRecords with the same tag to the detailAction with $newsRecords = $this->newsRepository->findDemanded($demand); (I not figured out how to use the function/$demand yet.

Related posts

Recent Viewed