<bdo id='AYazu'></bdo><ul id='AYazu'></ul>

    <legend id='AYazu'><style id='AYazu'><dir id='AYazu'><q id='AYazu'></q></dir></style></legend>
  1. <i id='AYazu'><tr id='AYazu'><dt id='AYazu'><q id='AYazu'><span id='AYazu'><b id='AYazu'><form id='AYazu'><ins id='AYazu'></ins><ul id='AYazu'></ul><sub id='AYazu'></sub></form><legend id='AYazu'></legend><bdo id='AYazu'><pre id='AYazu'><center id='AYazu'></center></pre></bdo></b><th id='AYazu'></th></span></q></dt></tr></i><div id='AYazu'><tfoot id='AYazu'></tfoot><dl id='AYazu'><fieldset id='AYazu'></fieldset></dl></div>

  2. <small id='AYazu'></small><noframes id='AYazu'>

    1. <tfoot id='AYazu'></tfoot>

      如何向 Zend Framework 2 添加自定义视图助手

      How to add custom view helpers to Zend Framework 2(如何向 Zend Framework 2 添加自定义视图助手)
    2. <legend id='dMMWP'><style id='dMMWP'><dir id='dMMWP'><q id='dMMWP'></q></dir></style></legend>
            <tbody id='dMMWP'></tbody>
          <tfoot id='dMMWP'></tfoot>
          • <bdo id='dMMWP'></bdo><ul id='dMMWP'></ul>
                <i id='dMMWP'><tr id='dMMWP'><dt id='dMMWP'><q id='dMMWP'><span id='dMMWP'><b id='dMMWP'><form id='dMMWP'><ins id='dMMWP'></ins><ul id='dMMWP'></ul><sub id='dMMWP'></sub></form><legend id='dMMWP'></legend><bdo id='dMMWP'><pre id='dMMWP'><center id='dMMWP'></center></pre></bdo></b><th id='dMMWP'></th></span></q></dt></tr></i><div id='dMMWP'><tfoot id='dMMWP'></tfoot><dl id='dMMWP'><fieldset id='dMMWP'></fieldset></dl></div>

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

                本文介绍了如何向 Zend Framework 2 添加自定义视图助手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我之前问过这个问题,我在那里得到了很好的答案.但是,这是针对 beta4 的,不再有效.

                I have earlier asked this question, and I got good answers there. However, that was for beta4, and no longer works.

                那么我在哪里以及如何将我自己的视图助手添加到 ZF2?

                So where and how do I add my own view helpers to ZF2?

                推荐答案

                你应该像这样将它们添加到你的 module.config.php 下的 view_helpers 下:

                You should add them to your module.config.php under view_helpers like this:

                'view_manager' => array(
                    'template_path_stack' => array(
                        'ModuleName' => __DIR__ . '/../view',
                    ),
                ),
                
                'view_helpers' => array(
                    'factories' => array(
                        'showmessages' => function($sm) {
                            $helper = new ModuleNameHelperMessageShower();
                            // do stuff with $sm or the $helper
                            return $helper;           
                        },
                    ),
                    'invokables' => array(
                        'selectmenu' => 'ModuleNameHelperSelectMenu',   
                        'prettyurl'  => 'ModuleNameHelperPrettyUrl',
                    ),  
                ),
                

                这里我展示了两种创建助手的方法.如果它们只需要实例化,只需将它们的名称(包括命名空间)添加为 invokables.如果您需要对它们或 ServiceManager 进行处理,请通过 factories 关键字创建它们.

                Here I show two ways of creating the helpers. If all they need to do is to be instantiated, just add their name (including namespace) as invokables. If you need to do stuff with them or the ServiceManager, create them through the factories keyword.

                这篇关于如何向 Zend Framework 2 添加自定义视图助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Zend_Controller_Router_Exception: quot;xyzquot; is not specified(Zend_Controller_Router_Exception:“xyz;未指定)
                Zend_Db_Table subquery(Zend_Db_Table 子查询)
                pcntl_fork and the MySQL connection is gone(pcntl_fork 和 MySQL 连接消失了)
                Change layout in the controller of Zend Framework 2.0(在 Zend Framework 2.0 的控制器中更改布局)
                Zend Mail Gmail SMTP(Zend 邮件 Gmail SMTP)
                Zend_Form: how to check 2 fields are identical(Zend_Form:如何检查 2 个字段是否相同)

                  <tfoot id='YyOwe'></tfoot>

                    <tbody id='YyOwe'></tbody>
                      <bdo id='YyOwe'></bdo><ul id='YyOwe'></ul>

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

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

                        <legend id='YyOwe'><style id='YyOwe'><dir id='YyOwe'><q id='YyOwe'></q></dir></style></legend>