-- minglee <[EMAIL PROTECTED]> wrote
(on Tuesday, 31 July 2007, 09:41 AM -0700):
> 
> Hi, Joo, Mathew and Joe,
> I solved the problem using redirect:
> $this->_redirector->gotoUrl('/my-controller/my-action/param_name/param_data');

Here's a better way:

    $this->_helper->redirector('my-action', 'my-controller', 'default', 
array('param_name' => 'param_data'));

I call it "better" because it builds the URL for you, and allows you to
easily add as many key/value pairs as you might need.

Another fun one is to use named routes. Assume you have a route called
'news' that matches the following:

    /news/:action/:id

You could then do this:

    $this->_helper->redirector->gotoRoute(
        array('action' => 'view', 'id' => 3),
        'news'
    );

and it would build the appropriate redirect for you. This method is nice
because you can then modify the route at any time, and the redirect will
*still* work.

> If use render, there are two problems:
> 1) parameters can not be passed on to action/view,

You're supposed to set the view parameters prior to rendering:

    $this->view->foo = 'bar';
    $this->view->bar = 'baz';
    $this->render('bazbat');

> 2) The header of the rendered view is not changed.

What header are you talking about? HTTP headers? <head> in your HTML?
I'm afraid I don't understand what you're attempting to accomplish.

> minglee wrote:
> > Having been working with ZF for couple of weeks, I am still confused and
> > even angry with "render"!
> > Are there any tutorials that can explain clearly how render works?
> > My recent problem in my project:
> > After login, the user should be rendered to his page. In my case, that
> > will be: action--'view', and id (user's id) --'1' (for example). So I used
> > $this->render('view/id/1'), but a uncaught error appeared. If I used 
> > $this->render('view'), no error but no message passed too.
> > Anybody could help?

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to