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

Multisite themes

Hello,

I am usunig multi-module application: fronted and backend. The modules have separate views (default structure).

My application will be multisite. Default the structure of the view in frontend is common to all domains (app/frontend/views/). I would like to make additional templates for domains.

Is it possible to do ? If exists Main Layout for domain1.com (themes/domain1.com/main.volt) load... If exists Controller Layout for domain1.com (themes/domain1.com/layouts/index.volt) load... If exists* Action View for domain1.com (themes/domain1.com/index/index.volt) load...

*If NOT exist, load the default from views.

-app
  |-frontend
    |-views
      |-index
        |-index.volt
      |-layouts
        |-index.volt
      |-main.volt
    |-themes
      |-domain1.com
        |-index
          |-index.volt
        |-layouts
          |-index.volt
        |-main.volt
      |-domain2.com
        |-main.volt
      |-domain3.com
        |-main.volt

Alternatively, move the themes folder to views ? Please suggestions

My suggestion is to set template in controller based on domain. But the template folder need to be in the views folder.

Refer https://docs.phalcon.io/en/latest/reference/views.html#hierarchical-rendering controller layout

edited Aug '16

https://monkpal.com/Multisite-Set-up-with-shared-views-controllers-and-modals-Phalcon

https://forum.phalcon.io/discussion/12677/multisite-set-up-with-shared-views-controllers-and-models#C38165

multisite/shared
├── apps
│   ├── common
│   │   ├── controllers        (Register namespace Common/Controller)
│   │   │   ├── IndexController.php   
│   │   │   ├── LoginController.php
│   │   │   └── ProductsController.php
│   │   ├── models             (Register namespace Common/Model)
│   │   │   └── Products.php  
│   │   └── views
│   │       ├── login
│   │       │   └── index.volt
│   │       └── products
│   │       |    └── index.volt
|   |       └──index.volt   
│   ├── example.com
│   │   ├── controllers
│   │   │   ├── IndexController.php (extend Common/Controller)
│   │   │   ├── LoginController.php  (extend Common/Controller)
│   │   │   ├── ProductsController.php (extend Common/Controller)
│   │   │   └── UsersController.php   Site Specific Controller
│   │   ├── models
│   │   │   └── Products.php (extend Common/Model)
|   |   |   └── Users.php (Site Specific Model)
│   │   └── views
│   │       └── products             (Other view templates will refer to Common view folder)
│   │           └── index.volt
│   ├── example2.com
│   │   ├── controllers
│   │   │   ├── IndexController.php (extend Common/Controller)
│   │   │   ├── ProductsController.php (extend Common/Controller)
│   │   │   └── SitespecificController.php   Site Specific Controller
│   │   ├── models
│   │   │   └── Products.php (extend Common/Model)
|   |   |   └── SiteSpecific.php (Site Specific Model)
│   │   └── views
│   │       └── sitespecific        (Other view templates will refer to Common view folder)
│   │           └── index.volt
└── public
    └── example.com   (Will contain Js CS Images to support site specific theme)
    └── example2.com  (Will contain Js CS Images to support site specific theme)
    └── index.php