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]
}
I have just implemented the given code for my fried website and it was successful. Thanks for sharing the code here.
ReplyDeleteDrupal web developer
Magnificent items from you, man. I have realise your stuff preceding to and you are just too excellent. I really like what you have came by here, absolutely like what you are saying and the way in which you state it. You make it amusing and you still be careful of to hold it sensible. I can not delay to read far more from you. This is really a magnificent post.
ReplyDeleteiphone app developer for hire | iphone custom development | Offshore Software Development Company
This comment has been removed by the author.
ReplyDeleteHey, nice site you have here! Keep up the excellent work! ios developer
ReplyDeleteAll RSS feed content is updated each time there is something new in target web page.
ReplyDeleteMobile Application Development Company
I have read this blog post It is easy and simple code for creating rss feed content Thanks for sharing!!
ReplyDeleteHire Angularjs Developers | Truck Dispatch Software | Taxi App Development