Hi,
Price Tapestry is installed on a subdirectory of my site http://www.domain.com/shopping
On my main page at http://www.domain.com I would like to display a random product or two as a way of driving my site visitors to my shopping directory.
How can I include a random listing on an external page?
Thanks
Richard
Thanks David,
I received the following message - index.php is my front page where I wanted to install the random product.
Fatal error: Call to undefined function database_queryselect() in /home/babyecom/public_html/index.php on line 102
Thanks
Richard
Hi Richard,
That would imply that $path_to_pricetapestry is not correct for your setup, as it means the Price Tapestry include files could not be included.
If you modify:
$path_to_pricetapestry = "shopping/";
and change shopping/ to whatever directory Price Tapestry is installed that should do the trick. If you're not sure what value to use, if you could email me (reply to your reg code or forum registration email) a link to your a) Price Tapestry main page and b) the location of this file that you want to include the random products i'll try and work out what it should be for you...
Cheers,
David.
Hi Richard,
Yes - that can be done. There was a similar thread for reviews recently, here's the code modified to select 2 random product and display a link to those products. There could be performance issues selecting random products if you have a very large database (see this thread for details) so if you do find that this is too slow we can implement a similar change here...
<?php
$path_to_pricetapestry = "shopping/";
require($path_to_pricetapestry."includes/config.php");
require($path_to_pricetapestry."includes/tapestry.php");
require($path_to_pricetapestry."includes/database.php");
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 2";
if (database_querySelect($sql,$rows))
{
foreach($rows as $product)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."product/".tapestry_hyphenate($product["name"]).".html";
}
else
{
$href = $config_baseHREF."products.php?q=".urlencode($product["name"]);
}
// if you want to display the product image here it is in
// the variable $product["image_url"]
print "<a href='".$href."'>".$product["name"]."</a><br />";
}
}
?>
Hope this helps,
Cheers,
David.