-- Matthias Coy <[EMAIL PROTECTED]> wrote
(on Wednesday, 30 July 2008, 08:52 PM +0200):
> I'm new to the framework, and I'm kind of stuck. I have a simple ..
> you can say blog, so that I can learn how things work in the Zend
> Framework.
> 
> I have a index, as in http://localhost/index/index. Of course I have a
> userlist, which would be http://localhost/users. So if I want to edit
> one of the users, my URL is s.th. like
> http://localhost/users/edit/id/1. So far so good.
> 
> This URL is created like that:
> 
> <a href="<?php echo $this->url(array('controller'=>'users',
> 'action'=>'edit', 'id'=>$user->id)); ?>">edit</a>
> 
> I have another URL to create a user which is:
> 
> <a href="<?php echo $this->url(array('controller'=>'users',
> 'action'=>'new')); ?>">Add a new user</a>
> 
> Now my problem: When I click on 'edit', the URL (and the page :) )
> changes to "http://localhost/users/edit/id/1"; which is correct. Than,
> I click on the 'Home' button (created via
> $this->url(array('controller'=>'index','action'=>'index')) ) the URL
> is now like this:
> 
> http://localhost/index/index/id/1
> 
> the index/index part is ok, but why is there still the id=1 part? And
> much more important: how can I get rid of it :)

By default, the url helper uses any matched parameters in the current
route. You can disable that by passing a false value for the third
argument:

    $this->url(array('controller'=>'index','action'=>'index'), 'default', false)

(The named route is the second argument; in this case, you're using the
'default' route)

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to