Feature #8989

Search path for fluid template files

Added by Christian Winther over 10 years ago. Updated almost 9 years ago.

Status:
Needs Feedback
Priority:
Could have
Assignee:
-
Category:
View
Target version:
-
Start date:
2010-07-22
Due date:
% Done:

0%

Estimated time:
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


Files

fluid_patch.diff (7.79 KB) fluid_patch.diff Christian Winther, 2010-07-22 10:27

Also available in: Atom PDF