[TYPO3-mvc] using views from a controller in another controller - possible or not?

Dustin Kinney dustin at kinney.ws
Wed Sep 22 18:59:16 CEST 2010


  hi dennis

thanks for the promising input. interesting approach. hope i can solve 
my problem with the help of your code-snippets. only problem is that the 
extension i want to use isnt coded yet ^^ (team development)
will need to wait a bit or set up a quick test extension. however thanks 
a ton!

cheers
dustin


Am 22.09.10 18:23, schrieb Dennis Ahrens:
> Hi again,
>
> i've tested the approach and the result is the following code:
>
> class Tx_FhhForschungsprojekte_Controller_PersonController extends 
> Tx_FhhPersonen_Controller_PersonController {
>
> /**
> * Initializes the view before invoking an action method.
> *
> * We change the template paths here to point to fhh_personen extension.
> *
> * @param Tx_Extbase_View_ViewInterface $view The view to be initialized
> * @return void
> * @api
> */
> protected function initializeView(Tx_Extbase_MVC_View_ViewInterface 
> &$view) {
> $templatePath = 
> t3lib_div::getFileAbsFileName('EXT:fhh_personen/Resources/Private/Backend/Templates/');
> $layoutPath = 
> t3lib_div::getFileAbsFileName('EXT:fhh_personen/Resources/Private/Backend/Layouts/');
> $partialPath = 
> t3lib_div::getFileAbsFileName('EXT:fhh_personen/Resources/Private/Backend/Partials/');
>
> $view = $this->objectManager->getObject('Tx_Fluid_View_TemplateView');
> $controllerContext = $this->buildControllerContext();
> $view->setControllerContext($controllerContext);
>
> $view->setTemplateRootPath($templatePath);
> $view->setLayoutRootPath($layoutPath);
> $view->setPartialRootPath($partialPath);
>
> if (method_exists($view, 'injectSettings')) {
> $view->injectSettings($this->settings);
> }
> $view->initializeView(); // In FLOW3, solved through Object Lifecycle 
> methods, we need to call it explicitely
> $view->assign('settings', $this->settings); // same with settings 
> injection.
> }
>
> }
>
> I'm not really happy with this solution, as i had to repeat code that 
> is executed before.
>
> The reason, why i had to copy so much code from the controllers 
> resolveView-method is, that extbase, if there is no viewfile found, 
> instantiates another view-template-class.
>
> Maybe somebody more common with fluid and the MVC package in extbase 
> has another, better solution.
>
> regards
> Dennis
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


More information about the TYPO3-project-typo3v4mvc mailing list