收录日期:2019/12/11 19:02:50 时间:2011-12-21 11:41:35 标签:php,zend-framework

I have in my config.ini the titles of my pages In my Bootstrap.php I have

$title  = $config->title;
Zend_Registry::set('title',$title);
$view->headTitle($title);

In my layout.phtml I have:

echo $this->headTitle();

That does not work. The title is blank. What should I do?

Do you return the view in the bootstrap after you are done with it?

return $view;

As lznogood pointed out, are you setting the view correctly in the boostrap class?

It should look something like:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    function _initView()
    {
        $view = new Zend_View($this->getOptions());
        ...
        $view->headTitle($title);

        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
            'ViewRenderer'
        );
        $viewRenderer->setView($view);

        return $view;
    }    // Added missing '}' brace
}

Another example can be found here.

Aren't you forgetting to read it back from the Registry? You can do that with

Zend_Registry::get('title');