View Full Version : Categories tag in RSS feed
se.nsuo.us
12-23-2005, 04:18 AM
As many of you might be aware that RSS search engines use the <category> tag for the items in RSS feed to classify/tag the items making them easier to find in tags/categories that *you* have specified. PP does not add this tag - to remedy this I hacked the following code into index.php -
Add just below line - $body = strip_tags( $body );
$query2 = mysql_query("SELECT {$pixelpost_db_prefix}categories.name FROM {$pixelpost_db_prefix}catassoc , {$pixelpost_db_prefix}categories WHERE {$pixelpost_db_prefix}categories.id = {$pixelpost_db_prefix}catassoc.cat_id AND image_id = $id");
$categories = "";
while(list($category) = mysql_fetch_row($query2)){
$categories .="<category>$category</category>";
}
Then just add $categories to the $output - just after </link> should be fine
However do note that it is not a good policy to hack index.php unless you realise all the risks and headaches involved (read you will have to redo all the changes in next upgrade) on second thoughts it would be good idea to add this code to the main distribution itself
Devs?
tinyblob
12-23-2005, 08:45 AM
very good post, glad you put the warning in there ;)
if you're interested in syndication/tags with reference to pixelpost i may get in touch with you, i'm working on something you might be interested in.
se.nsuo.us
12-23-2005, 08:52 AM
@tinyblob - sure send me a message, I would be very interested to see what is being done...
Joe[y]
12-23-2005, 12:41 PM
it will be part of the next main release.
thanks!
tinyblob
12-23-2005, 01:27 PM
']it will be part of the next main release.
surely you mean.. "we'll keep this in mind for the next main release"
Joe[y]
12-23-2005, 02:51 PM
yeah. what he said ^
raztazor
09-17-2007, 10:20 AM
As many of you might be aware that RSS search engines use the <category> tag for the items in RSS feed to classify/tag the items making them easier to find in tags/categories that *you* have specified. PP does not add this tag - to remedy this I hacked the following code into index.php -
Add just below line - $body = strip_tags( $body );
$query2 = mysql_query("SELECT {$pixelpost_db_prefix}categories.name FROM {$pixelpost_db_prefix}catassoc , {$pixelpost_db_prefix}categories WHERE {$pixelpost_db_prefix}categories.id = {$pixelpost_db_prefix}catassoc.cat_id AND image_id = $id");
$categories = "";
while(list($category) = mysql_fetch_row($query2)){
$categories .="<category>$category</category>";
}
Then just add $categories to the $output - just after </link> should be fine
However do note that it is not a good policy to hack index.php unless you realise all the risks and headaches involved (read you will have to redo all the changes in next upgrade) on second thoughts it would be good idea to add this code to the main distribution itself
Devs?
Hi
I've just implemented PP1.6 and thought I'd share an update to this original posting as I found this code really useful.
If you use PP 1.6 the place to implement the modified code is in includes/function_feeds.php.
I use feedburner for my RSS feed http://feeds.feedburner.com/AndrewsPhotoblog which uses an ATOM feed as a source and then wraps it up as RSS with frills. As such I had to modify the ATOM feed to include categories. The code is very similar except for ATOM categories the $$categories variable should be built up like this.
$categories .="<category scheme='http://www.yoururl.com/atom/ns#' term='$category'/>";
Note: The URL in the code can be a dummy one as it's not needed. The categories still appear in my RSS feedburner feed and technorati.
Thanks for the original post and the code.
Andrew
http://www.andrewor.com
Laprodo
09-22-2007, 01:25 AM
How can I insert tags? I mean which XML-Tag I need? "tag"?
Laprodo
09-22-2007, 08:06 AM
According to http://www.rssboard.org/rss-2-0#hrelementsOfLtitemgt is there no tag for "tag"
Ill write in some time about tags in RSS feed as I got it :D
Find in /includes/functions_feeds.php:
while(list($id,$datetime,$headline,$body,$image) = mysql_fetch_row($query))
{
$headline = pullout($headline);
$headline = htmlspecialchars($headline,ENT_QUOTES);
$image = $cfgrow['siteurl'].$rsspicdir.$image;
$datetime = strtotime($datetime);
$datetime =date("D, d M Y H:i",$datetime);
$datetime .= ' ' .$tzoner;
$body = pullout($body);
$body = stripslashes($body);
$body = strip_tags( $body);
$body = htmlspecialchars($body,ENT_QUOTES);
$body = ereg_replace("\n","\n<br />",$body);
$output .= "
<item>
<title>$headline</title>
<link>".$cfgrow['siteurl']."index.php?showimage=$id</link>
<description>
";
if($rsspicdir) $output .= " <img src="$image"><br/>
";
if($cfgrow['rsstype'] != 'O') $output .= " $body";
$output .= "
</description>
<pubDate>$datetime</pubDate>
<guid isPermaLink='true'>".$cfgrow['siteurl']."index.php?showimage=$id</guid>
</item>";
}
and change to:
while(list($id,$datetime,$headline,$body,$image) = mysql_fetch_row($query))
{
$headline = pullout($headline);
$headline = htmlspecialchars($headline,ENT_QUOTES);
$enclosure = $cfgrow['siteurl']."images/".$image;
$filesize = filesize("images/".$image."");
$image = $cfgrow['siteurl'].$rsspicdir.$image;
$datetime = strtotime($datetime);
$datetime =date("D, d M Y H:i",$datetime);
# GeoS Hack
$datetime2 = $datetime;
$datetime .= ' ' .$tzoner;
$body = pullout($body);
$body = stripslashes($body);
$body = strip_tags( $body);
$body = htmlspecialchars($body,ENT_QUOTES);
$body = ereg_replace("\n","\n<br />",$body);
# GeoS Hack
$rss_cat = '';
$cat_query = mysql_query("SELECT name FROM ".$pixelpost_db_prefix."categories AS a, ".$pixelpost_db_prefix."catassoc AS b WHERE b.image_id = ".$id." AND b.cat_id = a.id ORDER BY name asc");
while(list($cat_name) = mysql_fetch_row($cat_query))
{
$rss_cat .= " <category>".$cat_name."</category>\n";
}
$body = "<b>Title: ".$headline."</b>\n<br /><b>Date: ".$datetime2."</b>\n<br />\n<br /><p>" . $body . "</p>";
$output .= "
<item>
<title>$headline</title>
<link>".$cfgrow['siteurl']."rss/$id/</link>
<description>
";
if($rsspicdir) $output .= " <img src="$image"><br/>
";
if($cfgrow['rsstype'] != 'O') $output .= " $body";
$output .= "
</description>
<enclosure type=\"image/jpeg\" length=\"".$filesize."\" url=\"".$enclosure."\" />
<pubDate>$datetime</pubDate>
<guid isPermaLink='true'>".$cfgrow['siteurl']."rss/$id/</guid>
".$rss_cat." </item>";
}
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.