06.27 php saved
Nayosis
Tags add more
cakephp and rss  
Note
Nayosis did not leave a note
  1. // Le controller
  2.  
  3. $this->layout = 'xml';
  4.        
  5. //Dernières actus
  6.     $conditions['and'] = array(
  7.         'Article.datePublication ' => '<= CURRENT_DATE',
  8.         'Article.article_id' => '>= 0'
  9.     );
  10.     $fields = array('Article.id','Article.title', 'Article.slug', 'Article.datePublication', 'Article.chapeau', 'Sphere.title', 'Sphere.id', 'Sphere.slug');
  11.     $this->set('articles', $this->Article->findAll($conditions, $fields, 'Article.datePublication DESC', 10));
  12.  
  13.  
  14.  
  15. // La vue
  16. <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  17. <channel>
  18.     <title>monsite.fr : les news</title>
  19.     <link>http://www.monsite.fr/</link>
  20.     <description>Toutes les news</description>
  21.     <language>fr</language>
  22.     <pubDate><?php echo date("D, j M Y H:i:s", gmmktime()) . ' GMT'; ?></pubDate>
  23.     <generator>CakePHP</generator>
  24.     <webMaster>webmaster@monsite.fr</webMaster>
  25.     <?php foreach ($articles as $article): ?>
  26.     <item>
  27.        <title><?php echo utf8_encode($article['Article']['title']); ?></title>
  28.         <description><?php echo utf8_encode(strip_tags(html_entity_decode($article['Article']['chapeau']))); ?></description>
  29.         <link>http://www.monsite.fr/articles/view/<?= $article['Article']['id']; ?>/<?= $article['Article']['slug']; ?></link>
  30.         <guid>http://www.monsite.fr/articles/view/<?= $article['Article']['id']; ?>/<?= $article['Article']['slug']; ?></guid>
  31.         <pubDate><?php echo $time->nice($time->gmt($article['Article']['datePublication'])) . ' GMT'; ?></pubDate>
  32.     </item>
  33.     <?php endforeach; ?>
  34. </channel>
  35. </rss>
Parsed in 0.089 seconds, using GeSHi 1.0.7.14

Modify this Paste