Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Different Logo for each category?

Different Logo for each category?

Views: 568

Results 1 to 5 of 5
1 Jul 2016, 8:20 PM
#1
texasemt avatar

texasemt

New Zenner

Join Date:
Apr 2007
Location:
San Antonio, TX
Posts:
48
Plugin Contributions:
0

Different Logo for each category?

It is possible to have the main logo changed for each product category?

Index will have a logo, but if they go to category XX it has a different logo... category YY has a different logo... category ZZ has a logo, and so on...

I am sure this is possible, but I dont know exactly where to start.

Thanks!

EDIT*** Clarification... this is for the logo of the main page... not the logo display for the category itself.

2 Jul 2016, 2:01 AM
#2
texasemt avatar

texasemt

New Zenner

Join Date:
Apr 2007
Location:
San Antonio, TX
Posts:
48
Plugin Contributions:
0

Re: Different Logo for each category?

I found smart backgrounds in the download section... I will start with that.

2 Jul 2016, 3:58 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Different Logo for each category?

includes/your_template/common/tpl_header.php is (commonly) where the logo gets displayed.

And $current_category_id is the number of the currently-selected category.

2 Jul 2016, 5:29 AM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Different Logo for each category?

Just a thought experiment on my part, but thinking if you work with a copy of includes/templates/template_default/common/tpl_header.php or more specifically includes/templates/YOUR_TEMPLATE/common/tpl_header.php then if you find this section:

<!--bof-branding display-->
<div id="logoWrapper">
    <div id="logo"><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image($template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO_IMAGE, HEADER_ALT_TEXT) . '</a>'; ?></div>
<?php if (HEADER_SALES_TEXT != '' || (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2))) { ?>
    <div id="taglineWrapper">
<?php

You could modify it to do some sort of lookup (new function?) to identify your desired image, or you could use a "crafted" version of the logo filename so that if the filename exists to use your file and if not then the default:

<!--bof-branding display-->
<div id="logoWrapper">
    <div id="logo"><?php 
if (file_exists($template->get_template_dir('logo-' . $current_category_id . '.' . pathinfo(HEADER_LOGO_IMAGE, PATHINFO_EXTENSION), DIR_WS_TEMPLATE, $current_page_base,'images') . '/' . 'logo-' . $current_category_id . '.' . pathinfo(HEADER_LOGO_IMAGE, PATHINFO_EXTENSION))) {
  $current_logo = $template->get_template_dir('logo-' . $current_category_id . '.' . pathinfo(HEADER_LOGO_IMAGE, PATHINFO_EXTENSION), DIR_WS_TEMPLATE, $current_page_base,'images') . '/' . 'logo-' . $current_category_id . '.' . pathinfo(HEADER_LOGO_IMAGE, PATHINFO_EXTENSION);
} else {
  $current_logo = $template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO_IMAGE;
}
echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image($current_logo, HEADER_ALT_TEXT) . '</a>'; ?></div>
<?php if (HEADER_SALES_TEXT != '' || (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2))) { ?>
    <div id="taglineWrapper">
<?php

Probably a lot of other ways to accomplish it and didn't look for a ZC related function to obtain the file extension, but the above should allow filenaming to be similar to the original logo (meaning same file extension) but with a relatively straight forward filename convention of 'logo-$current_category_id', or the standard header logo if the previous don't exist. The logo is expected to be saved in the template directory images folder as allowed through applicable overrides identified in includes/classes/template_func.php.

2 Jul 2016, 8:32 AM
#5
texasemt avatar

texasemt

New Zenner

Join Date:
Apr 2007
Location:
San Antonio, TX
Posts:
48
Plugin Contributions:
0

Re: Different Logo for each category?

Thanks everyone... I used the mod I found above and I got it working properly. There was a little code I had to edit because of the responsive template in 1.5.5a, but I posted that in the support forum for the mod.

Thanks again!