Вот пример quick'n'dirty для вас, чтобы играть и приспособиться к вашим потребностям:
В контроллере:
public $components = array('RequestHandler');
public function sitemap()
{
Configure::write('debug', 0);
$articles = $this->Article->getSitemapInformation();
$this->set(compact('articles'));
$this->RequestHandler->respondAs('xml');
}
Ваш "Статья" Модель:
public function getSitemapInformation()
{
return $this->find('all', array(/* your query here */));
}
Вид:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($articles as $article): ?>
<url>
<loc><?php echo Router::url(/* generate the URLs here */); ?></loc>
<lastmod><?php echo $time->toAtom(/* last update time here */); ?></lastmod>
<changefreq>weekly</changefreq>
</url>
<?php endforeach; ?>
</urlset>
спасибо для примеров – meotimdihia
Не забудьте добавить публичный '$ components = array (' RequestHandler ');' в вашем контроллере (или AppController.php для доступа к общему доступу), чтобы это работало. – Coreus
@Coreus Я обновил ответ, спасибо! –