Automated Google Sitemap in cake tutorial
Automated Google Sitemap in cake tutorial
After reading this tutorial
http://mentalramblings.info/posts/view/automatic-sitemap-generation-with-CakePHP-1.2for adding an automated google sitemap to an cake site , i have created these files and
the sitemap.xml for blog posts is now autogenerated
Here is the sitemaps controller app/controllers/sitemaps_controller.php
* < xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
* <>
* <>http://www.example.com/
* <>2005-01-01 00:00:00
* <>monthly
* <>0.8
*
*
*
* The Sitemap must:
* Begin with an opening tag and end with a closing tag.
* Include a entry for each URL as a parent XML tag.
* Include a child entry for each parent tag.
*
*/
class SitemapsController extends AppController
{
var $components = array('RequestHandler');
var $helpers = array('Time', 'Xml');
var $name = 'Sitemaps';
var $uses = array('Post');
function sitemap ()
{
Configure::write ('debug', 0);
$posts = $this->Post->find('all', array('fields' => array('id', 'modified')), null, -1);
$this->set(compact('posts'));
$this->RequestHandler->respondAs('xml');
$this->viewPath .= '/xml';
$this->layoutPath = 'xml';
}
}
?>
here is the content for app/views/sitemaps/xml/sitemap.ctp
http://example.com/cake/posts/view/
toAtom($post['Post']['modified']); ?>
weekly
0.8
and finally add the router
in app/config/routes.php
Router::connect('/sitemap.xml', array('controller' => 'sitemaps', 'action' => 'sitemap'));
and load the site http://example.com/sitemap.xml in the browser
i agree with this article that is simpler to write hello world in php than using mod_perl
<?php
Than installing modperl and configure-ing the app (I'm working as sys admin)echo "goodbye world";
?>
maybe simple_mod_perl should interpret all *.pl and after that an use an templating system
<?perl
say "goodbye world";
?>