e-zone
07-14-2007, 08:29 AM
Got a RSS feed but it displays the hole article in the description on the feed.
i only want it to show the first 100 letters.
Im not a wiz at PHP so any help appreciated.
Here is the code:
// RSS FEED
function rss() {
$limit = s('rss_limit');
$query = "SELECT * FROM articles WHERE position = 1 ORDER BY date DESC LIMIT 0, $limit";
$result = mysql_query($query);
$filename = "rss.xml";
$header = "<?xml version=\"1.0\" ?>";
$header .= "<rss version=\"2.0\">";
$header .= "<channel>";
$header .= "<title>" .s('website_title'). "</title>";
$header .= "<description>" .s('website_title'). "</description>";
$header .= "<link>" .s('website'). "</link>";
$header .= "<copyright>Copyright " .s('website_title'). "</copyright>";
$footer = "</channel>";
$footer .= "</rss>";
$fh = fopen($filename, "w+");
fwrite($fh, $header);
while ($r = mysql_fetch_assoc($result)){
$date = date(s('rss_date_format'), strtotime($r['date']));
$pattern="'<[\/\!]*?[^<>]*?>'si";
$replace="";
$description = preg_replace($pattern, $replace, stripslashes($r['text']));
$item ="<item>";
$item .= "<title>". $r['title'] ."</title>";
$item .= "<description>". $description ."</description>";
$item .= "<pubDate>". $date ."</pubDate>";
$item .= "<link>". s(website) . find_cat_sef($r['category']). "/" .$r['seftitle']. "/</link>";
$item .= "</item>";
fwrite($fh, $item);
}
fwrite($fh, $footer);
fclose($fh);
echo "<script>self.location='" .s('website'). "rss.xml';</script>";
}
Thanks.
i only want it to show the first 100 letters.
Im not a wiz at PHP so any help appreciated.
Here is the code:
// RSS FEED
function rss() {
$limit = s('rss_limit');
$query = "SELECT * FROM articles WHERE position = 1 ORDER BY date DESC LIMIT 0, $limit";
$result = mysql_query($query);
$filename = "rss.xml";
$header = "<?xml version=\"1.0\" ?>";
$header .= "<rss version=\"2.0\">";
$header .= "<channel>";
$header .= "<title>" .s('website_title'). "</title>";
$header .= "<description>" .s('website_title'). "</description>";
$header .= "<link>" .s('website'). "</link>";
$header .= "<copyright>Copyright " .s('website_title'). "</copyright>";
$footer = "</channel>";
$footer .= "</rss>";
$fh = fopen($filename, "w+");
fwrite($fh, $header);
while ($r = mysql_fetch_assoc($result)){
$date = date(s('rss_date_format'), strtotime($r['date']));
$pattern="'<[\/\!]*?[^<>]*?>'si";
$replace="";
$description = preg_replace($pattern, $replace, stripslashes($r['text']));
$item ="<item>";
$item .= "<title>". $r['title'] ."</title>";
$item .= "<description>". $description ."</description>";
$item .= "<pubDate>". $date ."</pubDate>";
$item .= "<link>". s(website) . find_cat_sef($r['category']). "/" .$r['seftitle']. "/</link>";
$item .= "</item>";
fwrite($fh, $item);
}
fwrite($fh, $footer);
fclose($fh);
echo "<script>self.location='" .s('website'). "rss.xml';</script>";
}
Thanks.
