Multi theme volt

Hi, im new in Phalcon and i want to know if there is any way to have multi theme volt, for example:

  • app/views/default/index.volt
  • app/views/christmas/index.volt
  • app/views/halloween/index.volt


44.7k
edited Nov '14

Set a layouts and also partials folder relative to the views path. You'll find it in the views documentation. I like to set the views path to only paths that have an controller->action match and then beneath that (with '../') I keep the layouts folder. You can use template inheritance to get going and then fill the "blocks" or you can setup a partial template fragment that you include in each action. Another thing that you can do is to set the "layout" within the controller either for the entire controller in the initialize function or you can set it for each action. Then in the layout template call content() to include the action view within the layout. There are options for controlling which levels of rendering that are performed so you should read about that as well. The default should work though but I'm not sure.



18.5k

http://docs.phalconphp.com/en/latest/reference/volt.html#template-inheritance

  1. Create Volt inside the view service (I think you'll have that done).
  2. Create a .VOLT file that will act like a father layout (think on in as an HTML file when writting your code).
  3. Create a .PHTML file. This will be the action view. Extend ({% extends %}) from the file before, and write your code in the correct {% block %}. Note that you can do more template inheritance if you create more templates in a hierarchical way.