Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Theme Support for frontend

I am learning new for MVC and PHP Phalcon Framework.

I want, theme engine in my project. What is the best way for theme support ? I have 2 module in my project,* "frontend","backend"*

folder structure

modules;

/apps/frontend/

apps/backend/

for frontend;

"/public/themes/default"

"/public/themes/blue"

"/public/themes/red"

for backend;

"/apps/backend/views/theme/default"

"/apps/backend/views/theme/blabla"

what should I do for theme supporting ?

thanks for helping.



4.2k
Accepted
answer

Hi

I belive you can achive that using a depency injection and setViewsDir() according to your themes, if i understand the documentation correctly (http://docs.phalconphp.com/en/latest/reference/views.html).

Something like:

  $di->set('view', function() {

     //read your "theme" value before, assume that $heme_name variable contains your theme's directory name AKA theme name.
      $view->setViewsDir("../app/views/" . $theme_name);
  });

I have not tried this but i belive it should work fine :)