1

我是 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。我的链接代码应该是什么?

4

2 回答 2

2

Please try:

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
  ));

I included the plugin parameter, because you could encounter the same issue, if you use plugins.

Hope that helps.

于 2013-01-27T13:47:06.050 回答
0
<li><?php
      //pr($this->Html-);
      echo $this->Html->link('Entertainment', array(
          'admin' => false, // add this
          'controller' => 'UpcommingEntertainments',
          'action' => 'index'
      ));
      ?></li>

There is a good answer here offering a bit more indepth explanation.

于 2013-01-27T13:48:42.553 回答