Router::connect(
'/sitemap',
array ('controller' => 'sitemaps', 'action' => 'index', 'ext' =>
'rss')
);
On May 22, 7:35 pm, paulinthought <[email protected]> wrote:
> Hi,
>
> I'm trying to create an xml sitemap as described in the
> articlehttp://bakery.cakephp.org/articles/view/automatically-generate-dynami...
> I have followed the instructions there and I can now access my xml
> file in the browser at the addresshttp://localhost/project/sitemap
> My problem is that I want to access it athttp://localhost/project/sitemap.xml
> but when I type the .xml extension I get my default site layout and an
> Error: The requested address '/sitemap.xml' was not found on this
> server.
>
> My controller looks like this
> class SitemapsController extends AppController {
>
> var $components = array('RequestHandler');
> var $helpers = array('Time', 'Xml');
> var $name = 'Sitemaps';
> var $uses = array('NewsStory', 'Project');
>
> function index () {
> Configure::write ('debug', 0);
> $this->RequestHandler->respondAs('xml');
> $stories = $this->NewsStory->find('all', array('fields' =>
> array('id', 'title', 'created')), null, -1);
> $projects = $this->Project->find('all', array('fields' => array
> ('id', 'title', 'created')), null, -1);
> $this->set(compact('stories','projects'));
>
> $this->viewPath .= '/xml';
> $this->layoutPath = 'xml';
> }
>
> function beforeFilter() {
>
> $this->RequestHandler->setContent('xml',array('application/xml',
> 'text/xml'));
> $this->Auth->allow('index', 'sitemap');
> }
>
> }
>
> Also if I change my routes.php from
> Router::connect('/sitemap', array('controller' => 'sitemaps', 'action'
> => 'index'));
> to
> Router::connect('/sitemap.xml', array('controller' => 'sitemaps',
> 'action' => 'index'));
> I get a controller sitemapController not found error.
>
> Any help on this is much appreciated.
> Thanks.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---