I have build a CMS using Zend Framework (1.11). In the application I have two modules, one called ‘cms’ which contains all the CMS logic and an other ‘web’ which enables a user to build their own website around the CMS. This involves adding controllers/views/models etc all in that module.
The application allows you to serve multiple instances of the app with their own themes. These instances are identified by the hostname. During preDispatch(), a database lookup is done on the hostname. Based on the database field ‘theme’ the app then loads the required css files and calls Zend_Layout::setLayout() to change the layout file for that specific instance.
I want to extend this functionality to also allow the user to run different web modules based on the ‘theme’ db field. However, this is where I am stuck. As it is now, the web module serves the content for all the instances of the application.
I need the application to switch to a different web module based on the ‘theme’ database value (so indirectly the hostname). Any ideas?
Well, in my opinion,
You should write a front controller plugin for the web module, and do it so, that when you need another plugin, you can do so easily.
The front controller plugin should look something like this:
And the My_Controller_Plugin_Abstract, which is not an actual abstract and which your controller plugin extends,looks like this:
And in the end the front controller plugin itself, which decides which one of the specific front controller plugins you should execute.
}
If you have never done this, now is the time. 🙂
Also, to register your front controller plugin with the application, you should edit the frontController entry in your app configuration. I will give you a json example, i’m sure you can translate it to ini / xml / yaml if you need…
This might be a tad confusing, feel free to ask for a more detailed explanation if you need it.