FLOW3 – Using the same Layouts and Partials for different packages

By | 05/12/2011

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:

And any other controller:



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:

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:

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.

One thought on “FLOW3 – Using the same Layouts and Partials for different packages

  1. example

    Good info. Lucky me I discovered your blog by chance (stumbleupon).
    I’ve bookmarked it for later!


Leave a Reply to example Cancel reply

Your email address will not be published. Required fields are marked *