Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Nov 2006
    Location
    8,600 ft in the Rocky Montains of Colorado
    Posts
    23
    Plugin Contributions
    0

    Default Change Logo for Index Page Using CSS?

    Hello,

    I would like to have a different logo (larger) for my home/index page than for the rest of the site. I have created a index_home.css to change other aspects, but am wondering if it is possible to specify a different logo file for the home page using css (logo for the site and logo2 for the homepage). Or do I have to change the code in the tpl_header.php to include a conditional statement etc? I am new to zen cart, have some css knowledge and only a tiny bit of php, so please be gentle with me.

    Thank you!

  2. #2
    Join Date
    Nov 2006
    Location
    8,600 ft in the Rocky Montains of Colorado
    Posts
    23
    Plugin Contributions
    0

    Default Re: Change Logo for Index Page Using CSS?

    Yep, I needed a conditional statement in my tpl_header.php. It works!

  3. #3
    Join Date
    Nov 2007
    Location
    Texas
    Posts
    6
    Plugin Contributions
    0

    Default Re: Change Logo for Index Page Using CSS?

    Could you please post the conditional statement and where you put it in your tpl_header.php file? I've been trying to do the same thing.

    Thanks!!

  4. #4
    Join Date
    Nov 2006
    Location
    8,600 ft in the Rocky Montains of Colorado
    Posts
    23
    Plugin Contributions
    0

    Default Re: Change Logo for Index Page Using CSS?

    As this solution might be useful to others, I thought I’d post it.

    Disclaimer: Please not that I am not a programmer, rather I flail around until something I do works. That said, this is what I did and it worked for me. Please back up before you try this!

    1. I created a new css file entitled index_home.css in my css folder of my template.

    2. I created a new logo entitled logo2.gif and place it in my template/images.

    2. I copied and pasted the info for logo wrapper and logo from my stylesheet. This looks something like:

    #logoWrapper {
    margin: 0em 0em 0em 0em;
    padding: 1em 1em 0em 1em;
    background-color:;
    }

    #logo {
    float: left;
    }

    3. I renamed these to logo2Wrapper and logo2

    4. I edited the header.php file in includes/languages/English/my template to add the above:

    define('HEADER_ALT2_TEXT', 'My Store Name');
    define('HEADER_SALES2_TEXT', '');
    define('HEADER_LOGO2_WIDTH', '192px');
    define('HEADER_LOGO2_HEIGHT', '64px');
    define('HEADER_LOGO2_IMAGE', 'logo2.gif');

    5. I edited the tpl_header.php file in my template/common to include a reference to the new logo.

    On line 70, I removed:

    <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>


    And replaced it with:

    <?php if ($this_is_home_page) { ?>

    <div id="logoWrapper">
    <div id="logo"><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image($template->get_template_dir(HEADER_LOGO2_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO2_IMAGE, HEADER_ALT_TEXT) . '</a>'; ?></div>

    <?php
    }
    else
    {
    ?>
    <div id="logoWrapper2">
    <div id="logo2"><?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
    }
    ?>

    Because I am a computer idiot, I included all of my steps. Please forgive if some of this was already obvious to you.

    Good Luck!

  5. #5
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Change Logo for Index Page Using CSS?

    This is the right direction, but over-complicates it a little. Unless you need different text or the image is a different size, there is no need to duplicate the information in the header.php file and you could simply create the new file and use the following code snippet instead (i.e. no CSS additions)
    PHP Code:
    <?php $logo_image $this_is_home_page HEADER_LOGO2_IMAGE HEADER_LOGO_IMAGE?>
    <div id="logoWrapper">
    <div id="logo"><?php echo '<a href="' HTTP_SERVER DIR_WS_CATALOG '">' zen_image($template->get_template_dir($logo_imageDIR_WS_TEMPLATE$current_page_base,'images'). '/' $logo_imageHEADER_ALT_TEXT) . '</a>'?></div>
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  6. #6
    Join Date
    Nov 2007
    Location
    Texas
    Posts
    6
    Plugin Contributions
    0

    Default Re: Change Logo for Index Page Using CSS?

    Thank you Mountain Mama for the explanation and Kuroi for the simplification. Elegant and it works great!

    David

  7. #7
    Join Date
    Nov 2006
    Location
    8,600 ft in the Rocky Montains of Colorado
    Posts
    23
    Plugin Contributions
    0

    Default Re: Change Logo for Index Page Using CSS?

    Hello Koroi,

    Thank you for the simplification. My header image is larger than the images on the other pages. Could I still use your solution?

  8. #8
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Change Logo for Index Page Using CSS?

    Since you are changing several items, it would probably be best to pop back to the english/header.php file and do the changes there. I'd recommend replacing the existing definitions with these ...
    PHP Code:
    if ($this_is_home_page) {
      
    define('HEADER_ALT_TEXT''My Store Name');
      
    define('HEADER_SALES_TEXT''');
      
    define('HEADER_LOGO_WIDTH''192px');
      
    define('HEADER_LOGO_HEIGHT''64px');
      
    define('HEADER_LOGO_IMAGE''logo2.gif');    
    } else {
      
    define('HEADER_ALT_TEXT''My Store Name');
      
    define('HEADER_SALES_TEXT''');
      
    define('HEADER_LOGO_WIDTH''81px');
      
    define('HEADER_LOGO_HEIGHT''32px');
      
    define('HEADER_LOGO_IMAGE''logo.gif');

    ... tailored to your specific requirements of course.

    What this does is leave the constants that are defined the same, so you wouldn't normally need to make any changes to your tpl_header.php file, and would change your stylesheet only if your logo wrapper needs to be taller on the home page.

    However, somewhere you have lost the height and width parameters, so you also need to add them back in either by reverting to the original file or by using the following for the logo div
    PHP Code:
    <div id="logo"><?php echo '<a href="' HTTP_SERVER DIR_WS_CATALOG '">' zen_image($template->get_template_dir(HEADER_LOGO_IMAGEDIR_WS_TEMPLATE$current_page_base,'images'). '/' HEADER_LOGO_IMAGEHEADER_ALT_TEXTHEADER_LOGO_WIDTHHEADER_LOGO_HEIGHT) . '</a>'?></div>
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  9. #9
    Join Date
    Nov 2006
    Location
    8,600 ft in the Rocky Montains of Colorado
    Posts
    23
    Plugin Contributions
    0

    Default Re: Change Logo for Index Page Using CSS?

    Thank you!

  10. #10
    Join Date
    Oct 2007
    Location
    Kentucky - USA
    Posts
    428
    Plugin Contributions
    0

    Default Re: Change Logo for Index Page Using CSS?

    [FONT=Arial]The above was a great solution for the home page using [/FONT][FONT=Arial]
    $this_is_home_page

    [/FONT][FONT=Arial]However, I just want to change the LogoWrapper for only the define page about_us. I could not find a simular command for about_us page. [/FONT][FONT=Arial]My text and image size is the same for all headers. [/FONT][FONT=Arial]

    I have created a second header image headerbg2.jpg in includes/templates/MY TEMPLATE/images/

    My assumption is that I will need to change my tpl_header.php file or as indicated
    Quote Originally Posted by kuroi View Post
    ...Unless you need different text or the image is a different size, there is no need to duplicate the information in the header.php file and you could simply create the new file and use the following code snippet instead (i.e. no CSS additions)
    PHP Code:
    <?php $logo_image $this_is_home_page HEADER_LOGO2_IMAGE HEADER_LOGO_IMAGE?>
    <div id="logoWrapper">
    <div id="logo"><?php echo '<a href="' HTTP_SERVER DIR_WS_CATALOG '">' zen_image($template->get_template_dir($logo_imageDIR_WS_TEMPLATE$current_page_base,'images'). '/' $logo_imageHEADER_ALT_TEXT) . '</a>'?></div>
    First, what would this new file be called?
    Second, where would you put it?
    Third, what modifications would be necessary so this would work for the about_us define page?
    Fourth, is there another solution for this problem (i.e
    [/FONT][FONT=Arial]tpl_header.php)[/FONT][FONT=Arial]?

    Thanks,
    Sawhorse

    [/FONT]

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. how to change css for one ez-page?
    By blrw in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 9 Mar 2012, 12:10 PM
  2. Change header with logo on all pages except Index page
    By acreativepage in forum Templates, Stylesheets, Page Layout
    Replies: 12
    Last Post: 23 Feb 2010, 08:40 AM
  3. Loss of CSS styles images and main header logo on SSL when using the server's browser
    By oldwolfe in forum Installing on a Linux/Unix Server
    Replies: 1
    Last Post: 13 Oct 2009, 02:13 PM
  4. CSS/Logo Change with pages help
    By Zoethreads in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 9 Oct 2009, 07:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg