Creating Rss Page for our site using our Content:
function rssfeed() {
global $base_url;
$sp_name = arg(2); //(your content node id)
$node_names = node_get_types('names'); //(your content type name)
$title_name = $node_names[$sp_name] != '' ? $node_names[$sp_name] : $sp_name;
$query = "SELECT n.nid, n.type, n.title, nr.body, n.changed
FROM {node} n
JOIN {node_revisions} nr ON nr.nid = n.nid
WHERE n.type = '%s'"; //(contents for the rss)
$result = db_query($query, $sp_name);
//[ Creating Structure for rss Page ]
header("Content-Type: application/rss+xml; charset=iso-8859-1");
$rssfeed = '<rss version="2.0">
<channel>
<title>' . $title_name . '</title>';
while($row = db_fetch_array($result)) {
$nid = $row['nid'];
$src = 'node/'.$nid;
$url_alias = drupal_get_path_alias($src);
extract($row);
//encode description
//$contenttitle = utf8_decode($title);
//$contenttitle = str_replace('', '™', $contenttitle);
$contenttitle = html_entity_decode($title, ENT_QUOTES, "UTF-8");
//$contenttitle = str_replace(array('&' , '®'), array('&' , '®'), $contenttitle);
//encode description
$contentdesc = html_entity_decode(strip_tags($body), ENT_QUOTES, "UTF-8");
// $contentdesc = str_replace('&', '&', $contentdesc);
//Designing Each Rss
$url = $base_url . '/'.$url_alias;
$rssfeed .= '
<item>
<title>' .($contenttitle) . '</title>
<description>' . check_plain($contentdesc) . '</description>
<link>' . $url . '</link>
<pubDate>' . date("D, d M Y H:i:s O", $changed) . '</pubDate>
</item>';
}
$rssfeed .= '
</channel>
</rss>';
echo $rssfeed; //[Returning the rss structure]
}
function rssfeed() {
global $base_url;
$sp_name = arg(2); //(your content node id)
$node_names = node_get_types('names'); //(your content type name)
$title_name = $node_names[$sp_name] != '' ? $node_names[$sp_name] : $sp_name;
$query = "SELECT n.nid, n.type, n.title, nr.body, n.changed
FROM {node} n
JOIN {node_revisions} nr ON nr.nid = n.nid
WHERE n.type = '%s'"; //(contents for the rss)
$result = db_query($query, $sp_name);
//[ Creating Structure for rss Page ]
header("Content-Type: application/rss+xml; charset=iso-8859-1");
$rssfeed = '<rss version="2.0">
<channel>
<title>' . $title_name . '</title>';
while($row = db_fetch_array($result)) {
$nid = $row['nid'];
$src = 'node/'.$nid;
$url_alias = drupal_get_path_alias($src);
extract($row);
//encode description
//$contenttitle = utf8_decode($title);
//$contenttitle = str_replace('', '™', $contenttitle);
$contenttitle = html_entity_decode($title, ENT_QUOTES, "UTF-8");
//$contenttitle = str_replace(array('&' , '®'), array('&' , '®'), $contenttitle);
//encode description
$contentdesc = html_entity_decode(strip_tags($body), ENT_QUOTES, "UTF-8");
// $contentdesc = str_replace('&', '&', $contentdesc);
//Designing Each Rss
$url = $base_url . '/'.$url_alias;
$rssfeed .= '
<item>
<title>' .($contenttitle) . '</title>
<description>' . check_plain($contentdesc) . '</description>
<link>' . $url . '</link>
<pubDate>' . date("D, d M Y H:i:s O", $changed) . '</pubDate>
</item>';
}
$rssfeed .= '
</channel>
</rss>';
echo $rssfeed; //[Returning the rss structure]
}