Perforce Chronicle 2012.2/486814
API Documentation

P4Cms_Controller_Action_Helper_ViewRenderer Class Reference

Enhances ViewRenderer to provide themeing capabilities. More...

List of all members.

Public Member Functions

 init ()
 Extend init to make views theme-able by adding the the theme's (resolved) views directory to the path stack.

Detailed Description

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

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

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.

Returns:
void
    {
        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);
            }
        }
    }

The documentation for this class was generated from the following file: