开发者

How do I eliminate the views/scripts folder?

Let's say I'm tired of having to put my page 开发者_Python百科template folders under views/scripts and want to just put them under views, leaving out the "scripts" part of the path. How can I alter the config of ZendFramework to permit me to do that?


Try the following:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

// ...

    protected function _initView()
    {
        // Initialise the view
        $view = new Zend_View();
        $view->addScriptPath(APPLICATION_PATH.'/views');

        // set the configured view as the view to be used by the view renderer.
        $renderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
        $renderer->setView($view);

        return $view;
    }

// ...

}

The previous answer is missing the part where you set the view you have configured to have the additional script path to the View Renderer.

HTH.


See ZF Manual for Zend_View and place this in your bootstrap:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initView()
    {
        $view = new Zend_View();
        $view->setScriptPath('/some/new/path');   // overwrite any paths
        $view->addScriptPath('/some/other/path'); // adds additional paths
        $view->setEncoding('UTF-8');
        $view->doctype('XHTML1_STRICT');
        $view->headMeta()->appendHttpEquiv(
            'Content-Type', 'text/html;charset=utf-8'
        );
        $viewRenderer =
        Zend_Controller_Action_HelperBroker::getStaticHelper(
            'ViewRenderer'
        );
        $viewRenderer->setView($view);
        return $view;
    }
}

or configure your Ini for use with Zend_Application_Resource_View

resources.view.encoding = "UTF-8"
resources.view.basePath = APPLICATION_PATH "/views/scripts"
...

Note that the selected basePath assumes a directory structure of:

base/path/
    helpers/
    filters/
    scripts/

See also this tutorial by Padraic Brady.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜