【问题标题】:zend framework $this->url is not working correctlyzend 框架 $this->url 无法正常工作
【发布时间】:2013-12-09 14:02:45
【问题描述】:

我有一个链接可以转到更新屏幕,并且在更新屏幕中有一个后退按钮来加载索引。

*当前 url 是 * http://sample.com/demoZend/public/index/ 当我点击一个帖子时,我会把它带到这个 URL,http://sample.com/demoZend/public/index/update/id/1

现在这个视图中有一个按钮可以返回到index

<?php
$this->title = "Update post";
$this->headTitle('Update Post');

echo $this->form;
?>
<a href="<?php echo $this->url(array('controller'=>'index', 'action'=>'index')); ?>">Go Back</a>

问题是,当点击后退按钮时,这里是http://sample.com/demoZend/public/index/index/id/1 而不是http://sample.com/demoZend/public/index/index/

这个参数 id 仍然存在。 id/1 如何删除此参数并使 url 成为 public/index/index/

我是 zend 框架的新手。所以对于使用 zend 的人来说,这一定是一件小事。

【问题讨论】:

    标签: php zend-framework


    【解决方案1】:

    使用 Url Helper 上的重置参数,重置所有参数

    function url(array $urlOptions = array(), $name = null, $reset = false, $encode = true)

    echo $this-&gt;url(array('controller'=&gt;'index', 'action'=&gt;'index'), null, true);

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多