开发者

zend headtitle using zend_navigation

开发者 https://www.devze.com 2023-01-15 04:11 出处:网络
I am using zend_navigation for creating menu. Which works fine. Now i m looking if i can take current page and set it as page title using headTitle. Is there is any way to do that?

I am using zend_navigation for creating menu. Which works fine. Now i m looking if i can take current page and set it as page title using headTitle. Is there is any way to do that?

or

how can i use config files (.ini) f开发者_如何转开发or creating Pagetitle and meta data ?


In controller you can get current active page and get its's label. Then you cen set it as page title.

//get active page and its label
$activePage = $this->view->navigation()->findOneBy('active', true);
$label = $activePage->get('label');

//set page label as html title
$this->view->headTitle($label);

You could also write custom plugin to do it for you in every request:

class Plugin_NavigationTitle extends Zend_Controller_Plugin_Abstract
{
    function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        //get view
        $view = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view;

        //get active page and its label
        $activePage = $view->navigation()->findOneBy('active', true);
        $label = $activePage->get('label');

        //set page label as html title
        $view->headTitle($label);
    }
}
0

精彩评论

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