Hi David,
I'm trying to figure out the most 'efficient' (automated) way to display products on 'SPECIAL OFFER' on my website. At the minute I have the following setup:
Wordpress (in route)
PT (in /shopping/ subfolder)
Also, I use hardcoded category pages something like below:
http://mysite.com/shopping/red-widgets.php
http://mysite.com/shopping/blue-widgets.php
http://mysite.com/shopping/green-widgets.php
http://mysite.com/shopping/pink-widgets.php
http://mysite.com/shopping/purple-widgets.php
Is there a way that I can display particular products, that I know are currently on Special Offer, on the above pages. It would great if I could employ something like the Featured Products functionality where I can pick out 5 or 6 products. I'd obviously want to display a different group of 'Special Offers' on each category page.
Hope it's possible.
Regards,
Neil
Thanks David,
It kind of worked. However, doing it that way introduces some problems: because of the PT Theme I'm using it pulls in lots of other information that I don't want - Featured Products wrapper, etc. Also, the products displayed as an array doesn't really work for what I'm after.
Ok, let me take a step back. Basically on my category page the page is split in half (horizontally) using two DIVs. I'd like to display Special Offers in LH DIV as a list rather than as an array - with just Title, Image, Price.
Is there a more simple way to achieve this?
Hi Neil,
Just to clarify; is it purely the fact that it is being displayed by html/featured.php that is causing a problem. With an exclusive HTML module written just for this application it would be fine?
Cheers,
David.
Hi David,
I think so (see below). I had only mentioned using the 'featured products' functionality because that's what came to mind. But perhaps there's an easier way to display a list of products as a list?
Hi Neil,
Could you perhaps email me your example golfclubs.php script so that I can see how it is structured, and I'll suggest how to add the selected "Special Offer" products as a list into it (so that you can copy the method for the other files...)
Cheers,
David.
Hi David,
Just to revisit this topic...I'd like to do the same as this example but plug this into my template (similar to within DIVs). Did you have an idea or way to solve this when you replied:
"Just to clarify; is it purely the fact that it is being displayed by html/featured.php that is causing a problem. With an exclusive HTML module written just for this application it would be fine?"
Sounds like it would work really well for what I'm trying to accomplish.
Thanks! -Joe
Hi Joe,
It was simply that in the case above html/featured.php had already been
modified quite significantly, and therefore superfluous information was
being displayed that was not wanted in this application.
The solution if his also applies to your site is just to start with a
fresh copy of html/featured.php from the distribution, rename it, and
use the new file in place of html/featured.php in the above code...
Cheers,
David.
Hello Neil,
Sure - you can reuse the Featured Products code to do this.
To avoid too much code repetition in each of your special offer files, I would start by created a single script called featuredcode.php as follows:
featuredcode.php
<?php
$sequence = 1;
$sqlNames = array();
$sqlCase = "CASE name";
foreach($products as $product)
{
$sqlNames[] = "'".$product."'";
$sqlCase .= " WHEN '".database_safe($product)."' THEN ".$sequence++;
}
$sqlCase .= " END AS sequence";
$sqlIn = implode(",",$sqlNames);
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants, ".$sqlCase." FROM `".$config_databaseTablePrefix."products` WHERE name IN (".$sqlIn.") GROUP BY name ORDER BY sequence";
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("html/featured.php");
?>
...and then to call that, using your red-widgets.php example:
red-widgets.php
<?php
require("includes/common.php");
require("html/header.php");
$products = array("Red Widget 1","Red Widget 2"); // product list in order to be displayed
require("featuredcode.php");
require("html/footer.php");
?>
Cheers,
David.