Re: How to change name of view in controller?

2007-09-11 Thread Grant Cox

I would guess that changing $this->action  would change which view is
used by default, but instead I would recommend just having:

function widget(){
$render_view = 'widget';

if (condition) {
$render_view = 'edit_small';
} else
$render_view = 'edit_large';
}

if (condition1) {
return;
}

$this->render( $render_view );
}


On Sep 12, 4:03 pm, Mike52 <[EMAIL PROTECTED]> wrote:
> In a controller action, I want to set the name of the view that will
> be auto-rendered after the action. The render() method renders the
> view immediately. I only want to set the name.
>
> The reason is this: I have two views for editing a widget.
> The action looks like this:
>
> read widget
> if condition {
>   set view to edit_small.ctp} else
>
>   set view to edit_large.ctp}
>
> if condition1 {
>   return}
>
> if condition 2 {
>   return
>
> }
>
> So the action has multiple exit-points. If I were to use the render()
> method, I would have to do this at each exit point. It can be done, of
> course. But I was wondering whether there is a more elegant way.
>
> Thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



How to change name of view in controller?

2007-09-11 Thread Mike52

In a controller action, I want to set the name of the view that will
be auto-rendered after the action. The render() method renders the
view immediately. I only want to set the name.

The reason is this: I have two views for editing a widget.
The action looks like this:

read widget
if condition {
  set view to edit_small.ctp
} else
  set view to edit_large.ctp
}
if condition1 {
  return
}
if condition 2 {
  return
}

So the action has multiple exit-points. If I were to use the render()
method, I would have to do this at each exit point. It can be done, of
course. But I was wondering whether there is a more elegant way.

Thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---