|
Perforce Chronicle 2012.2/486814
API Documentation
|
Enhances ViewRenderer to provide themeing capabilities. More...
Public Member Functions | |
| init () | |
| Extend init to make views theme-able by adding the the theme's (resolved) views directory to the path stack. | |
Enhances ViewRenderer to provide themeing capabilities.
Themes can override the built-in view scripts by placing a custom view script in the appropriate place inside the theme directory. For example:
<theme-dir>/views/<module>/<controller>/<action>.phtml
| P4Cms_Controller_Action_Helper_ViewRenderer::init | ( | ) |
Extend init to make views theme-able by adding the the theme's (resolved) views directory to the path stack.
{
parent::init();
// if there is an active theme - add view and layout script paths.
if (P4Cms_Theme::hasActive()) {
// determine appropriate view scripts path for current request.
$dispatcher = $this->getFrontController()->getDispatcher();
$moduleName = $this->getRequest()->getModuleName();
$theme = P4Cms_Theme::fetchActive();
$path = $theme->getViewsPath();
if ($moduleName) {
$path .= "/" . lcfirst($dispatcher->formatModuleName($moduleName));
}
// add theme's view scripts path if needed.
if (!in_array($path . "/", $this->view->getScriptPaths())
&& is_dir($path)
) {
$this->view->addScriptPath($path);
}
}
}