Saturday, September 28, 2013

php themes

 php Themes

You can take advantage of themes, making it easy to switch the look and feel of your page quickly and easily.
To use themes, specify the theme name in your controller:
class ExampleController extends AppController {
    public $theme = 'Example';
}
Changed in version 2.1: Versions previous to 2.1 required setting the $this->viewClass = 'Theme'. 2.1 removes this requirement as the normal View class supports themes
You can also set or change the theme name within an action or within the beforeFilter or beforeRender callback functions:
$this->theme = 'AnotherExample';
Theme view files need to be within the /app/View/Themed/ folder. Within the themed folder, create a folder using the same name as your theme name. For example, the above theme would be found in /app/View/Themed/AnotherExample. Its important to remember that CakePHP expects CamelCase theme names. Beyond that, the folder structure within the /app/View/Themed/Example/ folder is exactly the same as /app/View/.
For example, the view file for an edit action of a Posts controller would reside at /app/View/Themed/Example/Posts/edit.ctp. Layout files would reside in /app/View/Themed/Example/Layouts/.
If a view file can’t be found in the theme, CakePHP will try to locate the view file in the /app/View/ folder. This way, you can create master view files and simply override them on a case-by-case basis within your theme folder.


example download: https://github.com/Rhym/cakeStrap

No comments:

Post a Comment