【问题标题】:cakephp link not workingcakephp链接不起作用
【发布时间】:2013-01-10 22:56:21
【问题描述】:

我是 php 和 cakephp 的新手。只是想制作简单的导航菜单。

<li><?php
      //pr($this->Html-);
      echo $this->Html->link('Entertainment', array(
          'controller' => 'UpcommingEntertainments',
          'action' => 'index'
      ));
      ?></li>

如果我在 www.example.com,它可以正常工作。问题是如果我在 /admin/* 并单击此链接,它会将我带到 www.example.com/admin/Entertainment,我想去 www.wxample.com/Entertainment。 我的链接代码应该是什么?

【问题讨论】:

    标签: cakephp cakephp-2.0


    【解决方案1】:
    <li><?php
          //pr($this->Html-);
          echo $this->Html->link('Entertainment', array(
              'admin' => false, // add this
              'controller' => 'UpcommingEntertainments',
              'action' => 'index'
          ));
          ?></li>
    

    有一个很好的答案here 提供了更深入的解释。

    【讨论】:

      【解决方案2】:

      请尝试:

      echo $this->Html->link('Entertainment', array(
            'controller' => 'UpcommingEntertainments',
            'action' => 'index',
            'admin' => false, // thats what you need
            'plugin' => false, // could be helpful if you plan using plugins
        ));
      

      我包含了插件参数,因为如果你使用插件,你可能会遇到同样的问题。

      希望对您有所帮助。

      【讨论】:

        猜你喜欢
        • 2013-09-06
        • 2011-12-25
        • 2015-06-09
        • 1970-01-01
        • 2017-04-03
        • 2014-12-24
        • 2015-04-26
        • 2012-10-07
        • 2012-08-05
        相关资源
        最近更新 更多