【问题标题】:How to define href of an anchor tag in html for zend framework 2?如何在 html 中为 zend 框架 2 定义锚标记的 href?
【发布时间】:2014-05-04 03:32:13
【问题描述】:

在模块\Application\config\module.config.php // 路由是这样的。

'application' => array(

            'type' => 'Literal',
            'options' => array(
                'route' => '/',
                'defaults' => array(
                    '__NAMESPACE__' => 'Application\Controller',
                    'controller' => 'Index',
                    'action' => 'index',
                ),
            ),
            'may_terminate' => true,
            'child_routes' => array(
                'default' => array(
                    'type' => 'Segment',
                    'options' => array(
                        'route' => '[:controller[/:action]][/:id]',
                        'constraints' => array(
                            'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                            'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        ),
                        'defaults' => array(
                        ),
                    ),
                ),
            ),
        ),

我有两个动作,即索引和存储。 我有一个控制器,即 IndexController

现在在我看来有布局,即 layout.phtml 在那个文件中我有一个锚标记。

<a href="?">store</a>

现在上面那行问号的答案是什么?

【问题讨论】:

    标签: zend-framework2


    【解决方案1】:

    您是否在询问如何输出指向您的某条路线的链接?如果是这样,请使用 URL 助手:

    <a href="<?=$this->url('application/default', array('controller' => 'index', 'action' => 'store')?>">store</a>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-22
      • 2017-05-06
      • 2020-11-15
      相关资源
      最近更新 更多