Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2006
    Posts
    10
    Plugin Contributions
    0

    Default How to add a static Banner to the tpl_main_page.php

    Please take a quick look at the following links http://www.dfwflyers.com/home.htmand http://www.dfwflyers.com/shoppingcart/

    I am creating this shopping cart for a friend and now he likes it so much he wants the shopping cart to be his website instead of the one he currently has.

    He wants to be able to put his .gif's and jpegs that he uses as static banners on his old site www.dfwflyers.com on to the new site and he would like to have the static banners placed right below the gray bar with the home link.

    Is there any possible way I can do this? Also he said he is willing to customize the banner so that it fits in the middle page.

    Please let me know how this can be done.

    Thanks,

  2. #2
    Join Date
    Jan 2006
    Location
    Los Angeles
    Posts
    11
    Plugin Contributions
    0

    Default Re: How to add a static Banner to the tpl_main_page.php

    Sure it can be done.

    But I recommend using a dynamic script to change the image, instead of hard coding it into the template. Use an include file, or if someone already created, a banner rotation module for Zen Cart.

    If not done already, it should be a straight forward array script. But you'll need to know some basic php.

  3. #3
    Join Date
    Aug 2006
    Posts
    10
    Plugin Contributions
    0

    Default Re: How to add a static Banner to the tpl_main_page.php

    ok i apologize for the duplicat post but Ajeh if you can help please?

    I have figured out how to add the image where I want it but that presented another problem and that is ever page I go to now has that imag on it. I would actually like to add different images on different pages but in the same place is that possible?

    Please someone help me with this, I am so close to finishing this project for my friend.

    http://www.dfwflyers.com/shoppingcart/

  4. #4
    Join Date
    Aug 2006
    Posts
    10
    Plugin Contributions
    0

    Default Re: How to add a static Banner to the tpl_main_page.php

    sorry for those that do not know how to add images like the one on my link above all you do is go to the tpl_main_page.php and within the <td/> place an <img src/> with the <td/> and that is how you place the image anywhere between the three columns be it left, right, or center.

    Be advised that the image will be shown on each page and I currently do not know how to show an image just on one page only. I am hoping someone can help me with that.

    Good luck to all :)

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: How to add a static Banner to the tpl_main_page.php

    If you look at the comments at the top of tpl_main_page.php, you will see examples of how to not display this or that on the main page. You can use the
    PHP Code:
    if($current_page_base == 'index' and $cPath == '') {
    your code here

    to display what you want only on the front page. This can be modified to refer to any page or combination of pages.

    One way to have different banners on many different pages would be similar to this (the PHP is not exactly correct, but gives the idea for developing):
    PHP Code:
    switch {
          case(
    $current_page_base == 'index' and $cPath == '');
                  
    your banner1 code here
          
    break;
          case(
    $current_page_base == 'index' and $cPath == '23');
                  
    your banner2 code here
          
    break;
          case(
    $current_page_base == 'shipping');
                  
    your banner3 code here
          
    break;

    This goes through the cases until it finds one that is true, executes the code there, and drops to the end of the switch. If none match, no banner is displayed on that page.

  6. #6
    Join Date
    Aug 2006
    Posts
    10
    Plugin Contributions
    0

    Default Re: How to add a static Banner to the tpl_main_page.php

    Thanks gjh2 that works out perfectly if you go to the link now you can see that the image is placed only on the front page. I used the if statement as a test but will be implementing the switch statement so that I may do this on all pages I would like to thanks!




  7. #7
    Join Date
    Sep 2007
    Location
    Tasmania
    Posts
    46
    Plugin Contributions
    0

    Default Re: How to add a static Banner to the tpl_main_page.php

    I can see I'm a couple of years behind here :) I'm organising for a banner box to show on specific pages and have added this code in the banner_box2.php file:

    if($current_page_base == 'index' and $cPath == '93') {

    before the line:

    require($template->get_template_dir('tpl_banner_box2.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_banner_box2.php');

    This successfully causes the banner_box2 to display when I select category 93. However, I'd like it to display in all the sub-categories of cat 93, as well as the product pages further down the tree. Is there a method of doing this without listing every instance of the $cPath?

  8. #8
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: How to add a static Banner to the tpl_main_page.php

    A quick way to do this is to type-cast $cPath into an integer, which has the effect of dropping any non-numeric characters and what follows them (like _123 from 93_123).


    if($current_page_base == 'index' and (int)$cPath == '93') {

  9. #9
    Join Date
    Sep 2007
    Location
    Tasmania
    Posts
    46
    Plugin Contributions
    0

    Default Re: How to add a static Banner to the tpl_main_page.php

    Thanks so much, Glenn. It works like a charm. Thanks for explaining the reasoning behind the (int) coding too.

    Kind regards

    Philip

 

 

Similar Threads

  1. how do i access require($body_code) found in tpl_main_page.php?
    By tcarden in forum Customization from the Admin
    Replies: 2
    Last Post: 11 Dec 2012, 01:46 AM
  2. SEO question,how to add prefix: 'wholesale' for the static Html url?
    By mybiz9999 in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 14 Jul 2010, 07:18 AM
  3. How Do I Wrap This Conditional Array in tpl_main_page.php?
    By limelites in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 8 Apr 2009, 10:15 AM
  4. how do I add the small banner link on the right side
    By liningyao in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 12 Oct 2008, 09:10 AM
  5. how to add images in the center column of tpl_main_page
    By djfranknitti in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 11 Sep 2006, 01:39 AM

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