Hi,
David, tried to make a rss.php that has random products in it but I'm a little stuck.
Could you take a look at it?
<?php
require("includes/common.php");
header("Content-Type: text/xml");
print "<?xml version='1.0' encoding='UTF-8'?>";
print "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'>";
print "<channel>";
print "<title>Sinterklaaskado's</title>";
print "<link>{link saved}</link>";
print "<description>Sinterklaaskado tips</description>";
print "<atom:link href='{link saved}' rel='self' type='application/rss+xml' />";
{
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 20";
}
if (database_querySelect($sql,$rows))
{
foreach($rows as $product)
{
print "<item>";
if ($config_useRewrite)
{
$href = "product/".tapestry_hyphenate($row["name"]).".html";
}
else
{
$href = "products.php?q=".urlencode($row["name"]);
}
/* print "<title>".$row["name"]."</title>";*/
print "<title>".$row["name"]." ".$row["price"]." EUR</title>";
print "<link>{link saved}".$config_baseHREF.$href."</link>";
print "<guid>{link saved}".$config_baseHREF.$href."</guid>";
print "<description><![CDATA[";
print "<a href='{link saved}".tapestry_buyURL($row)."'>";
print "<img border='0' width='150' src='".$row["image_url"]."' />";
print "</a>";
print $row["description"];
print "]]></description>";
print "</item>";
}
}
print "</channel>";
print "</rss>";
?>
I'm using 11/09A. After I removed the braces the feed is empty. Maybe the code is different for this Pricetapestry release?
Hi Marco,
I should have spotted this before - I just tested the code on my server, this line:
foreach($rows as $product)
...should just be:
foreach($rows as $row)
(as the body of the loop refers to $row, not $product)
Cheers,
David.
--
PriceTapestry.com
Hi Marco,
The only obvious problem I can see is where you have the braces surrounding the SQL statement:
{
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 20";
}
If you remove those leaving you with just the $sql = ... line that should be all it is...
Cheers,
David.
--
PriceTapestry.com