Hi David,
Is it possible to have category images ( like merchants images ).
Thx Henk
Thx,
I got it working with the product and now to the html/atoz file
is the code
<?php
if (file_exists("images/categories/".$product["category"]))
{
print "<img src='".$config_baseHREF."images/categories/".$product["category"]."' />";
}
?>
but where can i place it.
Thx HEnk
Hi Henk,
The existing code to display an item in html/atoz.php is line 43:
print "<p><a href='".$item["href"]."'>".$item["name"]."</a></p>";
Now, since this file is used for both merchant and brand A-Z, you need to check if you are displaying categories before checking for images with the above code.
In place of the above code, do something like this:
if ($_SERVER["PHP_SELF"] == $config_baseHREF."categories.php")
{
// new code for categories, the image will be a link....
if (file_exists("images/categories/".$item["name"]))
{
print "<a href='".$item["href"]."'>";
print "<img border='0' src='".$config_baseHREF."images/categories/".$item["name"]."' />";
print "</a>";
}
else
{
print "<p><a href='".$item["href"]."'>".$item["name"]."</a></p>";
}
}
else
{
// the original code
print "<p><a href='".$item["href"]."'>".$item["name"]."</a></p>";
}
Hope this helps!
Cheers,
David.
Hi Henk,
The page in your link does not have the categories URL, so the test in the code won't work. However, I went to the /categories.php link on your site and there were still no images; so it is down to one of the following tests in the new code:
if ($_SERVER["PHP_SELF"] == $config_baseHREF."categories.php")
{
// new code for categories, the image will be a link....
if (file_exists("images/categories/".$item["name"]))
If for testing purposes you could first change this as follows:
if (1)
{
// new code for categories, the image will be a link....
if (file_exists("images/categories/".$item["name"]))
This will always check for images and should fix the problem if $_SERVER["PHP_SELF"] is not set on your server. If that still doesn't work, try overriding the file exists link also; as follows:
if (1)
{
// new code for categories, the image will be a link....
if (1)
At this stage images should be displayed. If not, check the path to the images is valid (we can do this by looking at the IMG html that is generated by using View > Source, and comparing it to the actual path to the images).
Hope this helps,
Cheers,
David.
This is working and it takes the counting with it ( but still no images).
Thx Henk
Hi Henk,
I'm not sure what is going on now - i'm not seeing the category names on your site any more.
Can you email me your:
categories.php
html/atoz.php
...and i'll make some debug changes for you to find out why it's not working.
Also, I notice your link above is not your categories page... Have you copied the code from categories.php to display categories here?
Can you also send me a link to a product page where you have got your category images being displayed correctly so that I can compare the image URLs.
Cheers,
David.
Got it, when you pullout the code for counting products the images working.
Thx Henk
Hi David,
Can you provide an updated script for this that includes the merchant images in the atoz?
I tried to add this to the current (12/10B) without changing the merchant image (which I also need to display) and crashed it (blank page displays under category header).
Thanks,
John
Hello John,
12/10B already includes merchant logos displayed by the A-Z html module, so to add images for categories that can now be plumbed in to categories.php. Look for the following code at line 16:
$item["name"] = $product["category"];
...and REPLACE with:
$item["name"] = $product["category"];
if (file_exists("images/categories/".$product["category"]))
{
$item["logo"] = $config_baseHREF."images/categories/".$product["category"];
}
Cheers,
David.
--
PriceTapestry.com
What would be the code for 15/09A? I tried finding $item["name"] = $product["category"]; at line 16 but didnt see it. All I could find was $item["name"] = $category["name"];
Thanks,
Shaun
Hi Shaun,
categories.php now contains separate sections for handling Category A-Z depending on whether using category hierarchy or basic feed categories, so for 15/09A look for the existing code at line 80:
$item["name"] = $product["category"];
...and REPLACE with:
$item["name"] = $product["category"];
if (file_exists("images/categories/".$product["category"]))
{
$item["logo"] = $config_baseHREF."images/categories/".$product["category"];
}
Cheers,
David.
--
PriceTapestry.com
Hi Henk,
Straight forward to do; using the same technique as merchant logo modification.
First, create a directory for the category images, for example:
images/categories/
Then, load your category images into that directory with the same file names as the categories themselves, and not using an extenstion (e.g. .gif).... for example you might then have:
images/categories/Books
images/categories/Electronics
Finally, to use the images in the code, wherever you are displaying a product (or category list) you can use the category value to see if there is a category image and display it if so. For example, in html/product.php you could use the following code:
<?php
if (file_exists("images/categories/".$mainProduct["category"]))
{
print "<img src='".$config_baseHREF."images/categories/".$mainProduct["category"]."' />";
}
?>
Hope this helps!
Cheers,
David.