pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <legend id='udZ8q'><style id='udZ8q'><dir id='udZ8q'><q id='udZ8q'></q></dir></style></legend>
      <bdo id='udZ8q'></bdo><ul id='udZ8q'></ul>
      <i id='udZ8q'><tr id='udZ8q'><dt id='udZ8q'><q id='udZ8q'><span id='udZ8q'><b id='udZ8q'><form id='udZ8q'><ins id='udZ8q'></ins><ul id='udZ8q'></ul><sub id='udZ8q'></sub></form><legend id='udZ8q'></legend><bdo id='udZ8q'><pre id='udZ8q'><center id='udZ8q'></center></pre></bdo></b><th id='udZ8q'></th></span></q></dt></tr></i><div class="f5zjrp7" id='udZ8q'><tfoot id='udZ8q'></tfoot><dl id='udZ8q'><fieldset id='udZ8q'></fieldset></dl></div>

    1. <tfoot id='udZ8q'></tfoot>
      1. <small id='udZ8q'></small><noframes id='udZ8q'>

      2. ZF2 - 將控制器名稱放入布局/視圖中

        ZF2 - Get controller name into layout/views(ZF2 - 將控制器名稱放入布局/視圖中)
        <i id='1gX2q'><tr id='1gX2q'><dt id='1gX2q'><q id='1gX2q'><span id='1gX2q'><b id='1gX2q'><form id='1gX2q'><ins id='1gX2q'></ins><ul id='1gX2q'></ul><sub id='1gX2q'></sub></form><legend id='1gX2q'></legend><bdo id='1gX2q'><pre id='1gX2q'><center id='1gX2q'></center></pre></bdo></b><th id='1gX2q'></th></span></q></dt></tr></i><div class="bhv7dvv" id='1gX2q'><tfoot id='1gX2q'></tfoot><dl id='1gX2q'><fieldset id='1gX2q'></fieldset></dl></div>

        <legend id='1gX2q'><style id='1gX2q'><dir id='1gX2q'><q id='1gX2q'></q></dir></style></legend>

          <tbody id='1gX2q'></tbody>

        <small id='1gX2q'></small><noframes id='1gX2q'>

          <tfoot id='1gX2q'></tfoot>
              • <bdo id='1gX2q'></bdo><ul id='1gX2q'></ul>
                • 本文介紹了ZF2 - 將控制器名稱放入布局/視圖中的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我知道使用 ZF1,您將使用自定義視圖助手檢索模塊/控制器名稱,該助手將獲取單例 frontController 對象并在那里獲取名稱.

                  I know with ZF1 you would retrieve the module/controller name using custom View Helpers that would get the singleton frontController object and get the name there.

                  使用 ZF2,因為它們消除了框架的很多單例性質并引入了 DI,我在其中為該模塊中的所有控制器指定了別名......我可以想象我會通過訪問 DI 或也許將當前名稱注入到布局中.

                  Using ZF2 as they've abolished alot of the singleton nature of the framework and introduced DI where I've specified aliases for all of my controllers within this module... I can imagine I would get it through accessing the DI or perhaps injecting the current name into the layout.

                  任何人都知道你會怎么做.我想有一百種不同的方法,但是在嗅探了幾個小時的代碼之后,我真的無法弄清楚它現在是如何完成的.

                  Anyone got any idea how you would do it. I guess there a hundred different ways but after sniffing about the code for a few hours I can't really figure out how its meant to be done now.

                  我想要控制器名稱的原因是將其作為特定控制器樣式的類添加到主體中.

                  The reason I wanted the controller name is to add it to the body as a class for specific controller styling.

                  謝謝,多姆

                  推薦答案

                  ZF2 出來了,骨架也出來了.這是在骨架頂部添加的,所以它應該是你最好的例子:

                  ZF2 is out and so is the skeleton. This is adding on top of the skeleton so it should be your best example:

                  內部模塊.php

                  public function onBootstrap($e)
                  {
                      $e->getApplication()->getServiceManager()->get('translator');
                      $e->getApplication()->getServiceManager()->get('viewhelpermanager')->setFactory('controllerName', function($sm) use ($e) {
                          $viewHelper = new ViewHelperControllerName($e->getRouteMatch());
                          return $viewHelper;
                      });
                  
                      $eventManager        = $e->getApplication()->getEventManager();
                      $moduleRouteListener = new ModuleRouteListener();
                      $moduleRouteListener->attach($eventManager);
                  }
                  

                  實際的 ViewHelper:

                  The actual ViewHelper:

                  // Application/View/Helper/ControllerName.php
                  
                  namespace ApplicationViewHelper;
                  
                  use ZendViewHelperAbstractHelper;
                  
                  class ControllerName extends AbstractHelper
                  {
                  
                  protected $routeMatch;
                  
                      public function __construct($routeMatch)
                      {
                          $this->routeMatch = $routeMatch;
                      }
                  
                      public function __invoke()
                      {
                          if ($this->routeMatch) {
                              $controller = $this->routeMatch->getParam('controller', 'index');
                              return $controller;
                          }
                      }
                  }
                  

                  在您的任何視圖/布局中

                  Inside any of your views/layouts

                  echo $this->controllerName()
                  

                  這篇關于ZF2 - 將控制器名稱放入布局/視圖中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)

                      <bdo id='qrpbw'></bdo><ul id='qrpbw'></ul>
                      • <legend id='qrpbw'><style id='qrpbw'><dir id='qrpbw'><q id='qrpbw'></q></dir></style></legend>

                            <i id='qrpbw'><tr id='qrpbw'><dt id='qrpbw'><q id='qrpbw'><span id='qrpbw'><b id='qrpbw'><form id='qrpbw'><ins id='qrpbw'></ins><ul id='qrpbw'></ul><sub id='qrpbw'></sub></form><legend id='qrpbw'></legend><bdo id='qrpbw'><pre id='qrpbw'><center id='qrpbw'></center></pre></bdo></b><th id='qrpbw'></th></span></q></dt></tr></i><div class="bxdnj7j" id='qrpbw'><tfoot id='qrpbw'></tfoot><dl id='qrpbw'><fieldset id='qrpbw'></fieldset></dl></div>
                            <tfoot id='qrpbw'></tfoot>
                              <tbody id='qrpbw'></tbody>

                            <small id='qrpbw'></small><noframes id='qrpbw'>

                            主站蜘蛛池模板: 石英陶瓷,石英坩埚,二氧化硅陶瓷-淄博百特高新材料有限公司 | 聚天冬氨酸,亚氨基二琥珀酸四钠,PASP,IDS - 远联化工 | ISO9001认证咨询_iso9001企业认证代理机构_14001|18001|16949|50430认证-艾世欧认证网 | 碳钢法兰厂家,非标法兰,定制异型,法兰生产厂家-河北九瑞管道 | 凝胶成像仪,化学发光凝胶成像系统,凝胶成像分析系统-上海培清科技有限公司 | 十二星座查询(性格特点分析、星座运势解读) - 玄米星座网 | 99文库_实习生实用的范文资料文库站 | 大流量卧式砂磨机_强力分散机_双行星双动力混合机_同心双轴搅拌机-莱州市龙跃化工机械有限公司 | 防爆型气象站_农业气象站_校园气象站_农业四情监测系统「山东万象环境科技有限公司」 | 【化妆品备案】进口化妆品备案流程-深圳美尚美化妆品有限公司 | 考试试题_试卷及答案_诗词单词成语 - 优易学 | 冲击式破碎机-冲击式制砂机-移动碎石机厂家_青州市富康机械有限公司 | BAUER减速机|ROSSI-MERSEN熔断器-APTECH调压阀-上海爱泽工业设备有限公司 | WF2户外三防照明配电箱-BXD8050防爆防腐配电箱-浙江沃川防爆电气有限公司 | 合同书格式和范文_合同书样本模板_电子版合同,找范文吧 | 薪动-人力资源公司-灵活用工薪资代发-费用结算-残保金优化-北京秒付科技有限公司 | 收录网| 拖鞋定制厂家-品牌拖鞋代加工厂-振扬实业中国高端拖鞋大型制造商 | 警方提醒:赣州约炮论坛真的安全吗?2025年新手必看的网络交友防坑指南 | 礼仪庆典公司,礼仪策划公司,庆典公司,演出公司,演艺公司,年会酒会,生日寿宴,动工仪式,开工仪式,奠基典礼,商务会议,竣工落成,乔迁揭牌,签约启动-东莞市开门红文化传媒有限公司 | 云阳人才网_云阳招聘网_云阳人才市场_云阳人事人才网_云阳人家招聘网_云阳最新招聘信息 | 深圳市宏康仪器科技有限公司-模拟高空低压试验箱-高温防爆试验箱-温控短路试验箱【官网】 | 伊卡洛斯软装首页-电动窗帘,别墅窗帘,定制窗帘,江浙沪1000+别墅窗帘案例 | 聚合氯化铝-碱式氯化铝-聚合硫酸铁-聚氯化铝铁生产厂家多少钱一吨-聚丙烯酰胺价格_河南浩博净水材料有限公司 | 小型气象站_便携式自动气象站_校园气象站-竞道气象设备网 | 河南空气能热水器-洛阳空气能采暖-洛阳太阳能热水工程-洛阳润达高科空气能商行 | 深圳网站建设-高端企业网站开发-定制网页设计制作公司 | 焊缝跟踪系统_激光位移传感器_激光焊缝跟踪传感器-创想智控 | 冷水机,风冷冷水机,水冷冷水机,螺杆冷水机专业制造商-上海祝松机械有限公司 | 自动检重秤-动态称重机-重量分选秤-苏州金钻称重设备系统开发有限公司 | 脉冲布袋除尘器_除尘布袋-泊头市净化除尘设备生产厂家 | 焊接烟尘净化器__焊烟除尘设备_打磨工作台_喷漆废气治理设备 -催化燃烧设备 _天津路博蓝天环保科技有限公司 | 道康宁消泡剂-瓦克-大川进口消泡剂供应商 | 组织研磨机-高通量组织研磨仪-实验室多样品组织研磨机-东方天净 传递窗_超净|洁净工作台_高效过滤器-传递窗厂家广州梓净公司 | 宏源科技-房地产售楼系统|线上开盘系统|售楼管理系统|线上开盘软件 | 铝扣板-铝方通-铝格栅-铝条扣板-铝单板幕墙-佳得利吊顶天花厂家 elisa试剂盒价格-酶联免疫试剂盒-猪elisa试剂盒-上海恒远生物科技有限公司 | 海水晶,海水素,海水晶价格-潍坊滨海经济开发区强隆海水晶厂 | 河南空气能热水器-洛阳空气能采暖-洛阳太阳能热水工程-洛阳润达高科空气能商行 | 武汉高低温试验机-现货恒温恒湿试验箱-高低温湿热交变箱价格-湖北高天试验设备 | 400电话_400电话申请_866元/年_【400电话官方业务办理】-俏号网 3dmax渲染-效果图渲染-影视动画渲染-北京快渲科技有限公司 | 智能监控-安防监控-监控系统安装-弱电工程公司_成都万全电子 |