Hi David,
Is it possible to create an RSS feed for last 10 or 20 product's comments/reviews?
Cheers
kempo.
Thank you David. It works very well after changing the first 10 rows as follows:
require("includes/common.php");
//header("Content-Disposition: attachment; filename=reviews.xml");
//header("Content-Type: text/xml");
header('Content-Type: application/xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
echo '<?xml-stylesheet href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"?>' . "\n";
echo '<!-- RSS for ' . $config_title . ', generated on ' . date('r') . ' -->' . "\n";
print "<rss version='0.92'>";
Hello
I am trying to create an RSS feed and having problems. I have created a file names rss.php and uploaded to the root. I get this error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING on line 5
I used the same info that is displayed in this thread replacing example.com with my site info
Can you help me please
Bobby
Hello Bobby,
Something that happens occasionally when copying code from a forum is if your browser has rendered fancy quotes rather than "normal quotes" as fancy quotes are not valid PHP syntax.
That should be all it is, if you're still getting errors, if you could email me the rss.php file that you created I'll check it out for you...
Cheers,
David.
--
PriceTapestry.com
Hi Kempo,
Sure have a go with this which I've adapted quickly from the Product export RSS script..
<?php
require("includes/common.php");
header("Content-Disposition: attachment; filename=reviews.xml");
header("Content-Type: text/xml");
print "<?xml version='1.0' encoding='UTF-8'?>";
print "<rss>";
print "<channel>";
$sql = "SELECT * FROM `".$config_databaseTablePrefix."reviews` ORDER BY approved DESC LIMIT 10";
if (database_querySelect($sql,$rows))
{
foreach($rows as $row)
{
print "<item>";
if ($config_useRewrite)
{
$href = "reviews/".tapestry_hyphenate($row["product_name"]).".html";
}
else
{
$href = "reviews.php?q=".urlencode($row["product_name"]);
}
print "<title>".$row["product_name"]."</title>";
print "<link>http://www.example.com".$config_baseHREF.$href."</link>";
print "<description>".$row["comments"]."</description>";
print "</item>";
}
}
print "</channel>";
print "</rss>";
?>
Don't forget to replace www.example.com with your site's domain name; and you can change the number of results in the feed by adjusting the LIMIT value on line 8...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com