mark27uk3, on Sep 23 2005, 03:40 PM, said:
I am trying to acheive different header images for different boxes, I have tried to use the code from the array to acheive this but I either end up with all boxes with the same header image or no images at all.
Step 1:
Let's just make sure that we can get different images for each box. To simplify things at this stage, let's assume that the images will reside in the /images directory, and that the images are named the same as the box title. In other words, the box image for box1 will be named box1.gif, and reside at
http://yourdomain.com/images/box1.gif. The box image for nextbox would be named nextbox.gif.
In includes/boxes/more_categories.php, find this:
function tep_categories_box($boxId,&$infoBox,$follow_cPath,&$cPath_array)
{
global $languages_id;
$info_box_contents = array();
$info_box_contents[] = array('text' => $infoBox['name']);
and add one line to the end, so that it reads like this:
function tep_categories_box($boxId,&$infoBox,$follow_cPath,&$cPath_array)
{
global $languages_id;
$info_box_contents = array();
$info_box_contents[] = array('text' => $infoBox['name']);
echo '<img src="/images/' . $infoBox['name'] . '.gif">';
Save that and upload it. Refresh your shop page in your browser. Assuming you have the correct .gif files in the /images directory, you now have an image just above each More Categories infobox.
Step 2:
Now, since you are much better graphic artists than I, and have created header graphics that replace the functionality of the infobox header anyway, remove the line (immediately after the code we edited above) that says:
new infoBoxHeading($info_box_contents, false, false);
or
new infoBoxHeading($info_box_contents, true, false);
. Upload and refresh.
Viola! You now have unique header images for each more_categories infobox (assuming that you're one of the graphic artists I alluded to earlier, or that you know one)!
The next step would be to store each category box image name in the database (extending the existing table definition by one field), and reference it directly, instead of assuming that not only the image name is the same as the box name, but that the image is a .gif.
Any takers? I'm happy to do it, but have been REALLY busy lately. The solution posted here is just a hack, really, and ought to be done properly by putting it into the database. On second thought, the hack is fine. The whole contrib is a hack anyway, so why not?
-jared