If this tutorial is helpful to you, you can donate some money to the tutorial author via Paypal.

I had the problem that I want to set up a web project that contains multiple packages. It did take me some time to figure how to handle this and I am still sure, that it is not the best way. The following is, what I want to achieve.

I have a base package and multiple sub packages. The base package should contain the layout file that is used for all the other packages as well. So this part was not that hard. There is a function called setLayoutPathAndFilename that can be triggered in the initializeView function. So I build a base controller that I use to extend my action controllers and voila, I have the same layout in all packages that extend this base controller.

This looks like follows: 

/**
 * Abstract Controller for the FUGRM.Base package
 *
 * @FLOW3\Scope("singleton")
 */
class AbstractController extends \TYPO3\FLOW3\MVC\Controller\ActionController {
 
    public function initializeView(\TYPO3\FLOW3\MVC\View\ViewInterface $view) {
        $view->setLayoutPathAndFilename('../Packages/Application/FUGRM.Base/Resources/Private/Layouts/Index.html');
    }
 
}

And any other controller: 

class IndexController extends \FUGRM\Base\Controller\AbstractController {
}

Now comes the second part. There is a partial inside my layout. The navigation. I will have the same navigation for all packages. Not that hard. I just do the same thing, that I did for the layout for the partial. Function has a different name here and what you do is not setting the file, but setting the partial root path. So now we have the navigation available in every package.

But what if one of the sub packages wants to use partials? It does not make sense putting this partials inside the base package. So what to do?

Solution for me was, to change the path to the partials root folder. The complete thing looks like follows: 

/**
 * Abstract Controller for the FUGRM.Base package
 *
 * @FLOW3\Scope("singleton")
 */
class AbstractController extends \TYPO3\FLOW3\MVC\Controller\ActionController {
 
 public function initializeView(\TYPO3\FLOW3\MVC\View\ViewInterface $view) {
 $view->setLayoutPathAndFilename('../Packages/Application/FUGRM.Base/Resources/Private/Layouts/Index.html');
 $view->setPartialRootPath('../Packages/Application');
 }
 
}

Now we have the problem that all partials are search in Packages/Application, where of course are no partials at all. The solution for this is to use the full name for the partial.

For example: 

<f:render partial="FUGRM.Base/Resources/Private/Partials/Navigation" />

This works for me for now. But I am looking forward for any other solution. Didn’t find anything in the documentation and looking into the source code of FLOW3/Fluid did not help much.

One last thing I just forgot. To make the css and js work in your subpackages, you have to add the package to the layout HTML file. 

<link rel="stylesheet" href="{f:uri.resource(path: 'Css/Fonts.css', package: 'FUGRM.Base')}" type="text/css" media="all" />

Was this tutorial helpful? So, you can donate some money to the tutorial author via Paypal.