Feature #8989

Search path for fluid template files

Added by Christian Winther about 5 years ago. Updated over 3 years ago.

Status:Needs Feedback Start date:2010-07-22
Priority:Could have Due date:
Assigned To:- % Done:

0%

Category:View
Target version:-
Has patch:No

Description

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"

  • getTemplateRootPath()
  • getPartialRootPath()
  • getLayoutRootPath()

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

$this->view->addExtensionSearchPath($_YOUR_EXT_KEY);

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

fluid_patch.diff Magnifier (7.8 kB) Christian Winther, 2010-07-22 10:27

History

#1 Updated by Sebastian Kurfuerst about 5 years ago

  • Priority changed from Must have to Could have

#2 Updated by Bastian Waidelich almost 5 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?

#3 Updated by Lukas Rüegg over 4 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.

#4 Updated by Sebastian Kurfuerst about 4 years ago

  • Parent task set to #26658

#5 Updated by Sebastian Kurfuerst about 4 years ago

  • Parent task deleted (#26658)

#6 Updated by Sebastian Kurfuerst about 4 years ago

  • Tracker changed from Task to Feature

#7 Updated by Sebastian Kurfuerst about 4 years ago

  • Target version deleted (1.0 beta 2)

#8 Updated by Christian Müller over 3 years ago

  • Status changed from New to Needs Feedback
  • Has patch set to No

Does this still make sense? The discussion and code is v4 and I think for v4 Typoscript can do everything needed. FLOW3 needs a different approach anyway... So close this ticket?

Also available in: Atom PDF