Friday, October 8, 2010

Re: Redirect to XML

Read through the RequestHandler area of the cookbook then head over to
parse extension part of the router section. Lastly take a look at the
XML helper to output your content into xml. You'll get a good head
start on all you'll need to do to accomplish this.

http://book.cakephp.org/view/1291/Request-Handling

http://book.cakephp.org/view/945/Routes-Configuration#File-extensions-952

http://book.cakephp.org/view/1473/XML

The basic idea is pretty simple.
1) Setup your app to receive xml extensions
Router::parseExtension('xml');

2) Now setup an xml layout and view wherever you need it. Use the XML
helper in those areas.
Create Layout views/layouts/xml/default.ctp
Create Controller/Action xml views
-- views/some_controller/xml/some_action.ctp

3) Now that you have that all setup you can detect incoming extensions
and parse them however you choose with either the Router, or
RequestHandler.
function beforeFilter(){
if($this->RequestHandler->isMobile()){
$this->redirect(array('ext' => 'xml'));
}
}

That will redirect any action to its xml view if the incoming request
is detected as a mobile device.

Hope that gets you started. Good luck!

Nick

On Oct 8, 4:55 pm, calzone <calz...@gmail.com> wrote:
> I may be totally wrong, but my inclination would be to code it in
> beforeFilter() in app_controller.php... set the layout, the response
> type, and a flag in there
>
> On Oct 8, 3:07 pm, Jonas <jonas.sand...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I am creating a mobile application interface and I'd like to call the
> > regular webbaddresses but redirect the output to an XML view instead
> > of a HTML one.
>
> > Where do I add this functionality the simplest way? Do I just make a
> > check in beforeFilter if it's coming in from a mobile device or is
> > there a better way?
>
> > Thank you,
>
> > Regards,
> > Jonas

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate