Search path for fluid template files
|Status:||Needs Feedback||Start date:||2010-07-22|
|Priority:||Could have||Due date:|
I'm currently working on a project where multiple extensions need to share some generic views, as well as be able to overwrite them locally.
I have made a patch for fluid that should not break in BC, but add the option for the TemplateView class to scan multiple extensions for view files.
Simply put I have added an "addExtensionSearchPath" method to TemplateView that appends extensions to a flat array (if it haven't already been added)
I have also changed so the following methods has a new optional argument called "extension" to overwrite the normal behavior of just calling "getControllerExtensionKey"
The protected function expandGenericPathPattern has been updated to iterate the new extensionSearchPaths class property and build search paths like before for each extension.
With the path applied you simple have to do the following in your controller to add a new search path
The search paths is processed First In First Out (FIFO) style, so your current extension always takes precedence over any additional searchable extensions added later in the request cycle.
This patch greatly improves the flexibility of the fluid rendering system, and helps keeping things DRY in your apps.
I have attached my patch to this ticket
Updated by Bastian Waidelich almost 3 years ago
- Category changed from Core to View
I'm not sure about this one to be honest.. I think, the template path resolution is already quite complex.
Usually you would add TS constants for the template paths and override them to reside in your fileadmin/template... folder anyways. And then you can set them to the same path if you want to.
Have you tried to move reusable parts into partials?
Updated by Simon Tuck over 2 years ago
I'd say the ability to define template paths on a per plugin basis is a must have. Not being able to define and redefine template paths would severely limit the flexibility of any extbase plugins. A simple (and common) application would be when an extension is applied multiple times across a site, but with differing layouts and partials for each application. Limiting the root paths makes fluid an unattractive templating solution.