thanks for replies guys. :)

i came to a conclusion that i can't use render() function for this
purpose. reason is there are three callbacks i could place this call
in:
- AppController::beforeFilter() - won't work because it's called
before action
- AppController::beforeRender() - won't work because it'll go into
infinite loop (render() calls beforeRender())
- AppController::afterFilter() - won't work because rendering is
already done

only thing i see, that would solve this, is that some variable which
would specify name of view file is added to controller (like $layout),
and used in render() action to determine view file. if some other
solution doesn't come up, i'll post feature request. maybe i get
lucky. :)

cheers

On Nov 19, 8:25 am, David Roda <davidcr...@gmail.com> wrote:
> Last response I promise!
>
> I read the whole post this time... If you want to change the view that is
> rendered for an action you can manually call $this->render .  Also the
> target action can be tested for with $this->action if you need to test for
> specific cases.
>
>
>
> On Thu, Nov 19, 2009 at 2:22 AM, David Roda <davidcr...@gmail.com> wrote:
> > I'm sorry its late... I didn't even read your post... please ignore my
> > reply! =(
>
> > On Thu, Nov 19, 2009 at 2:21 AM, David Roda <davidcr...@gmail.com> wrote:
>
> >> I think you can use the RequestHandler component for this.
> >>http://book.cakephp.org/view/174/Request-Handling
>
> >> On Wed, Nov 18, 2009 at 10:31 PM, Dr. Loboto <drlob...@gmail.com> wrote:
>
> >>> There is a hack to render view from other folder: $this->render
> >>> ('..'.DS.'shared'.DS.'json');
>
> >>> On Nov 18, 6:13 pm, ddaffy <dda...@gmail.com> wrote:
> >>> > hi!
>
> >>> > i'm using Router::parseExtensions('json') to be able to request data
> >>> > delivered in json format, and i've been wondering if there's a way to
> >>> > change view file that will be used to render data?
>
> >>> > if action test from Examples controller ( /examples/test ) is
> >>> > requested, default view (app/views/examples/test.ctp) is rendered with
> >>> > default layout (app/views/layouts/default.ctp).
>
> >>> > if /examples/test.json is requested app/views/examples/json/test.ctp
> >>> > is rendered with app/views/layouts/json/default.ctp layout.
>
> >>> > because i use unified way for passing variables to view, i don't need
> >>> > every action to have different view for json extension (app/views/
> >>> > examples/json/test1.ctp, app/views/examples/json/test2.ctp...), and i
> >>> > would like to use e.g. app/views/shared/json.ctp. i know how to
> >>> > achieve this for single action, but i need a way to do this globally
> >>> > (in AppController).
>
> >>> > what i tried:
>
> >>> > funciton beforeRender() {
> >>> >         if ($this->RequestHandler->ext == 'json') {
> >>> >             $this->viewPath = 'shared';
> >>> >         }
>
> >>> > }
>
> >>> > results in rendering app/views/shared/<action_name>.ctp
>
> >>> > funciton beforeRender() {
> >>> >         if ($this->RequestHandler->ext == 'json') {
> >>> >             $this->render('/shared/json');
> >>> >             // or: $this->render('shared/json');
> >>> >             // or: $this->render(null, null, '/shared/json');
> >>> >             // or variations..
> >>> >         }
>
> >>> > }
>
> >>> > result is empty.
>
> >>> > also i saw solution with creating new view class that will override
> >>> > render function and customising it, but it sounds like overkill to
> >>> > me..
>
> >>> > ideal solution in addition to setting $viewPath ($this->viewPath =
> >>> > 'shared') would be to change name of view file that will be requested
> >>> > for rendering, but haven't found a way to do that.
>
> >>> > any ideas would be appreciated.
> >>> > thanks. :)
>
> >>> --
>
> >>> You received this message because you are subscribed to the Google Groups
> >>> "CakePHP" group.
> >>> To post to this group, send email to cake-...@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.c
> >>>  om>
> >>> .
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/cake-php?hl=.

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.


Reply via email to