We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Each theme, custom view file

Hi,

how to setup a view folder which accept custom view file for each theme?

For example I would like to have:

app/views/default/ => all defautl view files

app/views/custom/ => all view file of custom theme

Thanks!!

That directory structure will work. The trick is setting up your bootstrap file and your DI to have your View properly register which directory it should be looking in for View files.



8.3k

@quasipickle yes I was think about similar way, define a variable and setup view path based on this configuration

However, I would like to know if exist a way for do this within framework, something like wordpress child theme https://codex.wordpress.org/Child_Themes which allow you to override just a few view files and not all.

So the view engine check firstly if a view file exist into active theme folder, if not exist, then load default one.



43.9k
edited Jun '14

Class Phalcon\Mvc\View has a method "exists (unknown $view)", wich is not documented, but method's name doesn't offer many differents meanings.

Maybe, with this method you can test if theme view file exist and if not fallback to default view ...



8.3k

@phalcon can you please tell me if you can extend phalcon 2.0 for handle this?

@le51 thanks I will try what you suggest, but I think that this feature can be implemented in core template of phalcon.