O Guia Definitivo do Yii 1.1
O Guia Definitivo do Yii 1.1
O Guia Definitivo do Yii 1.1
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Note: Theme name is case-sensitive. If you attempt to activate a theme that <strong>do</strong>es not<br />
exist, <strong>Yii</strong>::app()->theme will return null.<br />
Creating a Theme<br />
Contents under a theme directory should be organized in the same way as those under<br />
the application base path. For example, all view files must be located under views, layout<br />
view files under views/layouts, and system view files under views/system. For example, if<br />
we want to replace the create view ofPostController with a view in the classic theme, we<br />
should save the new view file asWebRoot/themes/classic/views/post/create.php.<br />
For views belonging to controllers in a module, the corresponding themed view files should<br />
also be placed under the views directory. For example, if the aforementioned<br />
PostController is in a module named forum, we should save the create view file as<br />
WebRoot/themes/classic/views/forum/post/create.php. If the forum module is nested in<br />
another module named support, then the view file should beWebRoot/themes/classic/<br />
views/support/forum/post/create.php.<br />
Note: Because the views directory may contain security-sensitive data, it should be<br />
configured to prevent from being accessed by Web users.<br />
When we call render or renderPartial to display a view, the corresponding view file as well<br />
as the layout file will be looked for in the currently active theme. And if found, those files<br />
will be rendered. Otherwise, it falls back to the default location as specified by viewPath<br />
and layoutPath.<br />
Tip: Inside a theme view, we often need to link other theme resource files. For<br />
example, we may want to show an image file under the theme's images directory.<br />
Using the baseUrl property of the currently active theme, we can generate the URL for<br />
the image as follows,<br />
<strong>Yii</strong>::app()->theme->baseUrl . '/images/FileName.gif'<br />
Below is an example of directory organization for an application with two themes basic and<br />
fancy.