Try to put the "RequestHandler" into the components property. It
detects which content type is requested and sets the layout path
according to that.

If you want to set the layout and layoutPath manually do it this way:

class PostsController ...
    function index() {
       ....
       $this->layoutPath = 'xml';
       $this->layout = 'default'; // not needed because the defaut is
'default'

The XmlHelper should only be used in views. In Controllers and Models
you can use the core Xml class:

App::import('Core', 'Xml');
$item = array('Post' => array('id' => 23, 'title' => 'test'));

// transform an array to xml:
$Xml = new Xml($item);
$xml = $Xml->compose(true);  // returns xml (string) including the xml
header

// transform xml to an array:
$Xml = new Xml($xml);
$item = $Xml->toArray();

For more info see:
http://c7y.phparch.com/c/entry/1/art,cakephp-rest
http://api.cakephp.org/class_xml.html for more infos
http://php.net/manual/de/book.xml.php
http://api.cakephp.org/class_request_handler_component.html

-David


On 17 Okt., 13:47, "Liebermann, Anja Carolin"
<[EMAIL PROTECTED]> wrote:
> Hi everybody,
>
> I try to follow the sitemap tutorial, but have problems with the layout.
> If I callhttp://localhost/myapp/sitemap.xmlit tries to use the default.ctp in 
> the layouts root, which results in a complete mess.
> If I add
>         function index (){      
>                 $this->layoutPath('xml/');
>                 $this->layout('default');
> The error message is:
> Call to undefined method SitemapsController::layoutPath()
>
> So how can I get Cake to use my proper xml layout?
>
> Of course I have added the following to my router.php:
>
>         Router::parseExtensions('rss','xml');
>         Router::connect('/sitemap', array('controller' => 'sitemaps', 
> 'action' => 'index'));
>
> If I callhttp://localhost/myapp/sitemaps/
> It shows an empty page.
>
> So is something wrong with my routing?
>
> Thanks in advance!
>
> Anja
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:[EMAIL PROTECTED] Im Auftrag von 
> Liebermann, Anja Carolin
> Gesendet: Donnerstag, 16. Oktober 2008 12:18
> An: [email protected]
> Betreff: xmlwriter
>
> Hi Siegfried!
>
> Good idea! I will inhale this tutorial :-)
>
> If I get it right finally I even might write an own tutorial for export ;-)
>
> Anja
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:[EMAIL PROTECTED] Im Auftrag von 
> Siegfried Hirsch
> Gesendet: Donnerstag, 16. Oktober 2008 10:38
> An: [email protected]
> Betreff: Re: xmlwriter
>
> Take a look at this bakery article about Sitemaps, which are dynamisch XML 
> files generated from different models using find('all')
>
> http://bakery.cakephp.org/articles/view/automatically-generate-dynami...
>
> I think there you have all your answers.
>
>
>
> On Thu, Oct 16, 2008 at 8:29 AM, Liebermann, Anja Carolin <[EMAIL PROTECTED]> 
> wrote:
>
> > Hello everybody, hi Franky,
>
> > Thanks for your reply!
>
> > So XML seams to be a core helper. But I don't understand from where I get 
> > it working. Am I right if I use it in my controller?
> > I tried this in my_controller.php:
> >        var $helpers = array('Html', 'Form', 'Javascript', 'Xml');
>
> >        function xmlExport(){
> >                $xml = new XmlHelper();
> >        }
> > This gives me the error: Fatal error: Class 'XmlHelper' not found in
> > my_controller.php on line 353
>
> > What do I do wrong?
>
> > Installatioan questions:
> > Does anyone know if I have to install expat seperately or if it comes with 
> > cake? I guess not... And if not, how can I get cake to work with it?
>
> > Webservices: I found this tutorial:
> >http://www.littlehart.net/atthekeyboard/2006/11/29/using-cakephps-nati
> > ve-web-service-support/ But it seems to be for Cake1.1 and I have
> > galdly migrated to cake1.2 RC3
>
> > A Mysql export to XML wouldn't help because, what I need is a XML document 
> > which contains the information of about 5-10 connected tables in my 
> > database.
>
> > Thanks for any hint and help!
>
> > Anja
>
> > -----Ursprüngliche Nachricht-----
> > Von: [email protected] [mailto:[EMAIL PROTECTED] Im
> > Auftrag von francky06l
> > Gesendet: Donnerstag, 16. Oktober 2008 00:55
> > An: CakePHP
> > Betreff: Re: xmlwriter
>
> > Well check the xml helper and serialize method, if DB is big you might have 
> > to "paginate" it ..
> > I also believe that mysqldump can dump xml (not sure thought)...
>
> > On Oct 14, 5:46 pm, "Liebermann, Anja Carolin"
> > <[EMAIL PROTECTED]> wrote:
> >> I would be interested as well in any help on this topic.
>
> >> The cookbook isn't very verbose on
> >> this:http://manual.cakephp.org/view/623/Xml
>
> >> In the end I would like to make an XML export out of my database, but
> >> at the moment I  don't know how to get expat on my development server
> >> (WinXP) or on my production environment (Linux). And I have no clue
> >> how to talk to expat or if cake does it for me.
>
> >> Thanks for any help, hints and links in advance!
>
> >> Anja
>
> >> ________________________________
>
> >> Von: [email protected] [mailto:[EMAIL PROTECTED] Im
> >> Auftrag von .
> >> Gesendet: Sonntag, 12. Oktober 2008 05:53
> >> An: Cake PHP
> >> Betreff: xmlwriter
>
> >> has anybody worked with xmlwriter (or similar) with cakephp? thanks
>
> --
> Siegfried Hirsch
> hhS - Welserstr. 1 - 81373 München - (089) 5484 3564 - skype:shirsch Fax +49 
> - (0)89 - 943 992 698 -http://www.rss-blogger.dehttp://www.newsbee.deNewsBee 
> 2 - customized RSS solutionshttp://abo-stop.dejetzt mit kostenlosem 
> Kündigungsgenerator
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to