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

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.



8.7k
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 (https://docs.phalcon.io/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 :)