Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / How to add a static Banner to the tpl_main_page.php

How to add a static Banner to the tpl_main_page.php

Locked

Views: 1,965

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
10 Sep 2006, 7:43 AM
#1
djfranknitti avatar

djfranknitti

New Zenner

Join Date:
Aug 2006
Posts:
10
Plugin Contributions:
0

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 https://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,

10 Sep 2006, 9:22 AM
#2
cubeshark avatar

cubeshark

New Zenner

Join Date:
Jan 2006
Location:
Los Angeles
Posts:
10
Plugin Contributions:
0

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.

11 Sep 2006, 1:29 AM
#3
djfranknitti avatar

djfranknitti

New Zenner

Join Date:
Aug 2006
Posts:
10
Plugin Contributions:
0

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/

11 Sep 2006, 1:35 AM
#4
djfranknitti avatar

djfranknitti

New Zenner

Join Date:
Aug 2006
Posts:
10
Plugin Contributions:
0

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

11 Sep 2006, 2:20 AM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

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

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
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.
11 Sep 2006, 5:30 AM
#6
djfranknitti avatar

djfranknitti

New Zenner

Join Date:
Aug 2006
Posts:
10
Plugin Contributions:
0

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!

:yes:
:D
:smile:

23 Jul 2008, 12:44 PM
#7
geronimo avatar

geronimo

New Zenner

Join Date:
Sep 2007
Location:
Tasmania
Posts:
46
Plugin Contributions:
0

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?

23 Jul 2008, 1:33 PM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

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') {

23 Jul 2008, 1:39 PM
#9
geronimo avatar

geronimo

New Zenner

Join Date:
Sep 2007
Location:
Tasmania
Posts:
46
Plugin Contributions:
0

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