Archive for April, 2010
It’s been a little over six months since I first began to use Kohana framework for all PHP development, and I thoroughly love the system. The only issue I’ve had with Kohana is the lack of built in, intuitive support for dynamic themes. I was unable to find an easy method to set up a theme that automatically wraps itself around all pages, while remaining dynamic enough to change certain elements on a page to page basis.
Over the past few days, I have been exploring methods to do this, with the following requirements:
- Keep all theme files separate from the application
- Require no changes to existing controllers and views to implement or change a theme
- Allow multiple applications on the same Kohana build to use the same theme
- Provide support for cascading themes
After a few failed attempts, I have found a solution that covers all four requirements and is pretty easy to implement. Of course, it is easier to implement this from the start, but if you have an existing Kohana site, it shouldn’t be too difficult to integrate this theming setup into the site. The concept of the theme is simple: create a theme as a module and then use hooks to implement the theme elements as appropriate.