Forums / Basic Configuration / Category sidebox shows category image

Category sidebox shows category image

Locked

Views: 7,360

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
15 Sep 2006, 7:54 AM
#1
jojohi avatar

jojohi

New Zenner

Join Date:
Jun 2006
Posts:
13
Plugin Contributions:
0

Category sidebox shows category image

Hi, i am new using ZC for 2wks, and now I want to change the default category name to show the category image on the sidebox, any one can help?

6 Jan 2007, 8:25 AM
#2
stylefiremedia avatar

stylefiremedia

New Zenner

Join Date:
Jan 2007
Location:
Kansas City
Posts:
8
Plugin Contributions:
0

Re: Category sidebox shows category image

Found your post while searching for an answer to the same thing. No one seemed to know so I set out to solve it myself. And... I did!

Fairly simple.

File to edit:
includes/templates/YOUR_TEMPLATE/sideboxes/tpl_categories.php

**Please read up on the template override system. You will need to get the file from 'includes/templates/template_default/sideboxes/tpl_categories.php' first, then save in YOUR_TEMPLATE folder.

Images to Create:
** images/menu-YourCategoryName.jpg

** images/menu-Blank.jpg


**
STEP 1
Find:

$content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
(Line 34)

STEP 2
Just after that add:

// for adding image beside category name
$myCategoryName = $box_categories_array[$i]['name'];
if (file_exists('images/menu' . $myCategoryName . '.jpg')) {
$content .= '<img src="images/menu-' . $myCategoryName . '.jpg" border="0" alt="YOUR ALT TEXT ' . $myCategoryName . '" align="absmiddle" /> ';
} else {
$content .= '<img src="images/menu-Blank.jpg" border="0" alt="HeatherDidIt! ' . $myCategoryName . '" align="absmiddle" /> ';
}
// end adding image code

That's It!

Now all you have to do whenever you add a new category is put the image you want to show up beside the category name in the images folder named "menu-YourCategoryName.jpg"
*Be sure to create a blank same-sized image called "menu-Blank.jpg" also


IF YOU WANT TO USE THE MAIN CATEGORY IMAGE
You might try putting in this:

zen_image(DIR_WS_IMAGES . $categories_image, '', CATEGORY_ICON_IMAGE_WIDTH, CATEGORY_ICON_IMAGE_HEIGHT);
Where the <img> tag is above.


Hope that helps.

You can see my example here: http://www.heatherdidit.com

6 Jan 2007, 8:34 AM
#3
lala_g_clef_jewelry avatar

lala_g_clef_jewelry

Zen Follower

Join Date:
Apr 2006
Location:
Kansas
Posts:
233
Plugin Contributions:
0

Re: Category sidebox shows category image

that is very nifty looking...

ty.

G Clef Jewelry
Dichroic and Beaded Jewelry

12 Jan 2007, 5:59 AM
#4
mrbob avatar

mrbob

New Zenner

Join Date:
Jan 2007
Posts:
1
Plugin Contributions:
0

Re: Category sidebox shows category image

This is a cool little feature, thanks for the info, what I am wondering is.....
How could you use an image rolllover for the catagory text instead. so then
all the text catagory menus in the left main sidebox would be what ever jpeg image you define..

anyidea, I have not come close to finding out this any leads would be great

:D
-mrbob

13 Mar 2007, 6:56 AM
#5
stylefiremedia avatar

stylefiremedia

New Zenner

Join Date:
Jan 2007
Location:
Kansas City
Posts:
8
Plugin Contributions:
0

Re: Category sidebox shows category image

Ok, so I found a better way to do it.

This new method automatically changes the image beside the category link in the sidebox to what you have set as the main category image (Great for clients that want to update their own page).

It's all in the file:
***includes/templates/MY_TEMPLATE/sideboxes/tpl_categories.php
***(Uses Template Override System. You may need to open the same file from the template_default folder and resave in your custom template folder.)

Find (near line 34):

$content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';

After that, add:

// for adding image beside category name

// categories_image
$categorySelect = str_replace('cPath=','',$box_categories_array[$i]['path']);
$categories_image = zen_get_categories_image($categorySelect);
$myCategoryImage = zen_image(DIR_WS_IMAGES . $categories_image, '', '50', '75');
// categories_image

$content .= $myCategoryImage;

// end adding image code

**Notice the '50'. You can replace this with your number of choice to set the width of the sidebox category image. And/Or put a number in place of the '75' to set the height of the sidebox category image. Or set either to '' and the images orginal sizes will be used. You can also set one to a number and the other to '' if you just need to set one dimension and you want the image dimensions kept in tact.

27 Mar 2007, 8:55 AM
#6
Join Date:
Mar 2007
Posts:
6
Plugin Contributions:
0

Re: Category sidebox shows category image

mrbob:

This is a cool little feature, thanks for the info, what I am wondering is.....
How could you use an image rolllover for the catagory text instead. so then
all the text catagory menus in the left main sidebox would be what ever jpeg image you define..

anyidea, I have not come close to finding out this any leads would be great

:D
-mrbob
I'm new to ZenCart -- just using it for a few days now. I'd like to use JPGs for the sidebox category links instead of text. Would this work here, and maybe set the text in the CSS to be transparent or something (so the text would still differentiate the categories, but not show up)? A better way? Here's the site I'm working on. I've replaced the text in the footer with rollover images, but want to do something similar on the right sidebox. Help? http://theveryimage.com/zencart/

29 Mar 2007, 12:44 AM
#7
beth_katherine avatar

beth_katherine

Zen Follower

Join Date:
Feb 2007
Posts:
158
Plugin Contributions:
0

Re: Category sidebox shows category image

http://theveryimage.com/zencart/

Too cool. I love the way your background graphic covers the entire leftside. How did you do that?

Beth-Katherine

29 Mar 2007, 2:28 AM
#8
Join Date:
Mar 2007
Posts:
6
Plugin Contributions:
0

Re: Category sidebox shows category image

Well, thank you! I set the background-image in the body specs of the stylesheet.css, and set the background-repeat to no-repeat. I also set a background-color, so if the screen is large than the image, it shows up on the right as the background color and blends well.
Now if I could just get the sidemenu to work! :bored: I'm trying to adjust some setup information I found in the download section, but no joy yet.

29 Mar 2007, 9:02 AM
#9
Join Date:
Mar 2007
Posts:
6
Plugin Contributions:
0

Re: Category sidebox shows category image

In case anyone was following this thread and wanted to know how it turned out, I got the roll-over sidemenu to work with images and links to categories by using the Blank Sidebox from the Sideboxes section of the Downloads page.

Granted, I am a beginner at coding, but for me it was very difficult to follow the directions in the readme -- I think some of it wasn't just me, it's a little mixed up. The main issue I noticed was that there was no mention of how to add links for the category pages in tpl_categories_sidebox.php. I found that info on the help page "How do EZ-Pages work?" under the heading "Internal Link URL".
But it does work!

(Note: I did already have some jscript in place for the mouseover stuff to swap images.)

30 Mar 2007, 10:36 AM
#10
beth_katherine avatar

beth_katherine

Zen Follower

Join Date:
Feb 2007
Posts:
158
Plugin Contributions:
0

Re: Category sidebox shows category image

Awesome, you are my hero.

and here I have been feeling proud getting rid of the annoying whitespace between my header and logo!

I will be watching to see your products, if they are anything like your graphics I'll be buying soon.

Beth-Katherine

24 Jun 2007, 5:20 PM
#11
kittycat avatar

kittycat

New Zenner

Join Date:
Jun 2007
Posts:
72
Plugin Contributions:
0

Re: Category sidebox shows category image

StylefireMedia:

Ok, so I found a better way to do it.

This new method automatically changes the image beside the category link in the sidebox to what you have set as the main category image

I love this code you wrote- thank you so much for posting it!
My only question is - can I get the pix to show ON TOP of the categories text
instead of beside it.
Please take a look at my page: http://www.pinuppeepshop.com/
It would look much better with my layout if the text would be under the pix.

THANK YOU!

24 Jun 2007, 5:30 PM
#12
kittycat avatar

kittycat

New Zenner

Join Date:
Jun 2007
Posts:
72
Plugin Contributions:
0

Re: Category sidebox shows category image

OR even pictures INSTEAD of the text!
Does anyone know how to do it?
Thank you :smile:

25 Mar 2008, 1:02 PM
#14
hemz avatar

hemz

New Zenner

Join Date:
Dec 2007
Location:
brighton UK
Posts:
40
Plugin Contributions:
0

Re: Category sidebox shows category image

Hi that piece of code is very handy!

I'm new to zen and was wondering whether there is anyway to just use the top level categories image like this but dont have a sub category image for each of the sub cats?

http://peterreed.dev.whitehatmedia.com

any help very much appreciated - thanks!

it's better to light a candle than curse the darkness

search engine marketing