Hi David,
I am quite sure you answered this question before, but I simply cannot find the thread.
How can I integrate the featured product module into another website?
Cheers, IG
Hi David,
The other site is running on the same server.
Cheers, Ivo
Hi Ivo,
Here's the code from index.php that you need, together with modified paths to the include files. What you will need to do is edit the value of $path_to_pricetapestry to contain the full system path your Price Tapestry installation directory. If you're not sure what this path is, create a phpinfo() script in your Price Tapestry folder like this:
phpinfo.php
<?php
phpinfo();
?>
...and look for the value of _SERVER["SCRIPT_FILENAME"], which will be something like this:
/home/http/sites/example/htdocs/phpinfo.php
You will need to use the section in bold from the above example...
<?php
$path_to_pricetapestry = "/home/http/sites/example/htdocs/";
require($path_to_pricetapestry."includes/config.php");
require($path_to_pricetapestry."includes/tapestry.php");
require($path_to_pricetapestry."includes/translate.php");
require($path_to_pricetapestry."includes/database.php");
$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` ORDER BY sequence";
if (database_querySelect($sql,$rows))
{
$sqlNames = array();
foreach($rows as $featured)
{
$sqlNames[] = "'".$featured["name"]."'";
}
$sqlIn = implode(",",$sqlNames);
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE name IN (".$sqlIn.") GROUP BY name";
database_querySelect($sql,$rows);
$featured["products"] = $rows;
foreach($featured["products"] as $k => $product)
{
if ($config_useRewrite)
{
$featured["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
$featured["products"][$k]["reviewHREF"] = "review/".tapestry_hyphenate($product["name"]).".html";
}
else
{
$featured["products"][$k]["productHREF"] = "products.php?q=".urlencode($product["name"]);
$featured["products"][$k]["reviewHREF"] = "reviews.php?q=".urlencode($product["name"]);
}
}
}
if (isset($featured)) require($path_to_pricetapestry."html/featured.php");
?>
Hope this helps!
Cheers,
David.
Hi IG,
Is the other site running on the same server, or do you want to add the products to any site?
I think I remember somebody asking for a JavaScript "AdSense Style" solution that would show the featured products on any page on any website... is that what you're trying to do? Will try and find the code assuming my memory serves me correctly...
Cheers,
David.