quick & dirty banget rss feed di-smarty

27 April, 2006

vans neh rss-nya

	
....
$news_data = $news->getHeadlineNews();
$smarty->assign('news_data',$news_data['newsList']);
.....
	
/*misalkan memakai switch() */
....
case 'rss':
	header(\"Content-Type:  text/xml\"); // set biar outputnya jadi xml
	$pt_smarty->display('rss.tpl');
break;
......
	
#rss.tpl
<rss version=\"2.0\">
<channel>
<title>some-title</title>
<link>http://www.some-url.com/</link>
<description>some-url rss feed</description>
{section name=news loop=$news_data}
<item>
 <title>{$news_data[news].title}</title>
 <description>
  <![CDATA[{$news_data[news].content|truncate:300:\"...\"}]]>
 </description>
 {* kalo mo di-truncate *}
 <pubdate>
 {$news_data[news].time|date_format:\"%a, %b %d %Y %H:%M:%S\"}
 </pubdate>
 <guid>
  news.php?action=open&id={$news_data[news].news_id}
 </guid>
 <link>
  news.php?action=open&id={$news_data[news].news_id}
 </link>
 </item>
 {* kalo mo pake {sectionelse} terserah, itu bisa juga *}
{/section}
</channel>
</rss>
	

kalo mau menambahkan element yang lain di <item>, semacam <category> dll, tinggal ditambahkan aja okeh, ciao!
sorry ada escape char-nya, itu harusnya gag ada.

6 Comments »

The URI to TrackBack this entry is: http://dedenf.blogsome.com/2006/04/27/quick-dirty-banget-rss-feed-di-smarty/trackback/

  1. hehehe…
    makanya gw bikin manual… :D
    tapi rss kan ya ga repot2 amat…
    lagian gw bisa custom sendiri…

    hihihi

    Comment by didats — 27 April, 2006 @ 1:26 pm

  2. rss sux™

    2 kali baca, 2 kali kerja, 2 kali klik.

    hihihih

    Comment by lu.jipeng — 27 April, 2006 @ 6:01 pm

  3. #1 iya sih, jadi gak ribet. cuman ini buat menanggulangi supaya gak perlu masuk ke main code
    #2 ah elu mah sux2an mulu peng

    Comment by dedenf — 28 April, 2006 @ 2:56 am

  4. apaan siy? rss apaan?

    Comment by basibanget — 28 April, 2006 @ 12:44 pm

  5. ini resep masakan apa sih den?

    Comment by ndrit — 2 May, 2006 @ 12:47 am

  6. pelajaran apa lagi tuh suhu ???

    Comment by ciplok — 8 May, 2006 @ 1:48 am

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.