06.27 php saved
Nayosis
Tags add more
cakephp and rss  
Note
RSS Function doesn't work.
  1. //Le Controller
  2. function rss($articles){
  3.     $articles = $this->Article->find('all', array('order' => 'datePublication DESC', 'limit' => 10));
  4.     $this->set(compact('articles'));
  5. }
  6.  
  7. // La Vue
  8. <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  9. <channel>
  10.     <title>monsite.fr : les news</title>
  11.     <link>http://www.monsite.fr/</link>
  12.     <description>Toutes les news</description>
  13.     <language>fr</language>
  14.     <pubDate><?php echo date("D, j M Y H:i:s", gmmktime()) . ' GMT'; ?></pubDate>
  15.     <generator>CakePHP</generator>
  16.     <webMaster>webmaster@monsite.fr</webMaster>
  17.     <?php
  18.         e($rss->items($articles, 'sortieRSS'));
  19.  
  20.         function sortieRSS($article){
  21.             return array(
  22.                 'title' => utf8_encode($article['Article']['title']),
  23.                 'link'  => 'http://www.monsite.fr/articles/view/'.$article['Article']['id'],
  24.                 'description' => utf8_encode(strip_tags(html_entity_decode($article['Article']['chapeau']))),
  25.                 'pubDate' => $article['Article']['datePublication']
  26.         );
  27.         }
  28.     ?>
  29. </channel>
  30. </rss>
  31.  
Parsed in 0.073 seconds, using GeSHi 1.0.7.14

Modify this Paste