dongxian8048 2010-09-09 05:48
浏览 52
已采纳

zend headtitle使用zend_navigation

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) for creating Pagetitle and meta data ?

  • 写回答

1条回答 默认 最新

  • douye2488 2010-11-08 13:49
    关注

    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);
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分