Forums / Basic Configuration / How do i make banner ads appear on the front page only?

How do i make banner ads appear on the front page only?

Views: 28,387

Results 1 to 20 of 66
26 Jul 2007, 9:10 AM
#1
mjw2305 avatar

mjw2305

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

How do i make banner ads appear on the front page only?

I want to display banner ads in Header position 3, but i only want to show them on the home page of my website. Is there a simple piece of html code i can insert into the banner ad to hide it on all other pages?:frusty:

26 Jul 2007, 10:42 AM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: How do i make banner ads appear on the front page only?

No. But if you mean banner set 2 in the header, then you can change this> if (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) {to this> if (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2) && $this_is_home_page) {

Kuroi Web Design and Development | Twitter

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

30 Jul 2007, 8:55 AM
#3
mjw2305 avatar

mjw2305

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: How do i make banner ads appear on the front page only?

Thanks for the reply, but it is definately Header position 3 that i want to show on the main page only - any thoughts?

Thanks in advance

30 Jul 2007, 9:25 AM
#4
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: How do i make banner ads appear on the front page only?

Although described as header position 3 in Admin > Configuration > Layout Settings, banner group set3 is actually displayed in the center panel. You can make this for the home page only by making a similar change to that explained above in your tpl_main_page.php.

Kuroi Web Design and Development | Twitter

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

30 Jul 2007, 10:07 AM
#5
mjw2305 avatar

mjw2305

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: How do i make banner ads appear on the front page only?

I will definately try this, but can you please advise exactly what i need to change to achieve hiding banner set 3 on the main page - i have copied the text below from the tpl_main_page.php file, forgive my lack of knowledge, i m still in the process of learning about all this stuff

Many Thanks in advance

// the following IF statement can be duplicated/modified as needed to set additional flags
if (in_array($current_page_base,explode(",",'list_pages_to_skip_all_right_sideboxes_on_here,separated_by_commas,and_no_spaces')) ) {
$flag_disable_right = true;
}

$header_template = 'tpl_header.php';
$footer_template = 'tpl_footer.php';
$left_column_file = 'column_left.php';
$right_column_file = 'column_right.php';
$body_id = ($this_is_main_page) ? 'indexHome' : str_replace('_', '', $_GET['main_page']);
?>

RecordCount() > 0) {
?>

get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');?>

trail(BREAD_CRUMBS_SEPARATOR); ?>RecordCount() > 0) { ?> size('upload') > 0) echo $messageStack->output('upload'); ?> RecordCount() > 0) { ?>

get_template_dir('tpl_footer.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_footer.php');?>

30 Jul 2007, 11:49 AM
#6
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: How do i make banner ads appear on the front page only?

In default Zen Cart you would find the line in your tpl_main_page.php that is identical to the line to which I referred in my original post, except for referring to SET3 instead of SET2 and make the change that I recommended.

However, this line is not amongst the sample that your posted from your tpl_main_page.php file. This could mean that you haven't posted it all (it does look rather sparse) or that you are using a template whose author has removed it. Are you displaying this banner now?

Kuroi Web Design and Development | Twitter

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

30 Jul 2007, 12:19 PM
#7
mjw2305 avatar

mjw2305

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: How do i make banner ads appear on the front page only?

I don't have the banner that i want to display displaying right now, but i can make banners appear in the Header position 3, i agree that this looks sparse, it is possible that this file has been edited by the developers of the original template, as i have found many instances where this is the case.

can i add the text you refer to in your original reply?

or is it possible i have more than one file named tpl_main_page.php?

what file path should it be under?

30 Jul 2007, 12:50 PM
#8
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: How do i make banner ads appear on the front page only?

If you can make banners appear, then the code must be there. We're getting into territory now, where it would be easier to help you if I could see your site. Do you have a link to it?

Kuroi Web Design and Development | Twitter

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

30 Jul 2007, 4:45 PM
#9
mjw2305 avatar

mjw2305

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: How do i make banner ads appear on the front page only?

My mistake, for some reason my FTP program wasn't opening the file correctly, but i have resolved this and added the modifications as you suggested to the SET3 line, however i now have this error

Fatal error: Call to a member function on a non-object in /home/jane776/public_html/shop/includes/templates/template_default/common/tpl_main_page.php on line 102

Any ideas?

30 Jul 2007, 5:44 PM
#10
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: How do i make banner ads appear on the front page only?

A couple of things here. You shouldn't be making changes to the template_default files. You should only change your over-ride copy of them. I recommend reading up on over-rides in the FAQ.

Then onto why this isn't working and you are getting an error ... it does seem that there is a problem with either your version of Zen Cart not being up to date, or your template not supporting all Zen Cart functions. This is not easy to establish without more information about both and ideally seeing your site as well.

Kuroi Web Design and Development | Twitter

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

30 Jul 2007, 6:24 PM
#11
mjw2305 avatar

mjw2305

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: How do i make banner ads appear on the front page only?

Thanks

Here is the info you need

Zen Cart 1.3.7
Database Patch Level: 1.3.7
PHP Version 4.4.7
Template - Gloss Black

Site link
https://www.fantasysextoysrus.co.uk

Hope this is enough info

The Welcome greeting is currently in the Header 3 position

Many Thanks

30 Jul 2007, 7:33 PM
#12
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: How do i make banner ads appear on the front page only?

That's helpful but puzzling. The version of Zen Cart that you are using supports the $this_is_home_page variable, and Gloss Black plays nicely with it and doesn't over-ride the tpl_main_page file, so I'm puzzled as to where the code that you posted earlier came from, unless you have amended it yourself.

Also, I can see no reason why the code posted earlier shouldn't work, or evidence on your site of the error that you reported. Could you post the change that you made and a few lines before and after it and detail the circumstances in which the error occurs.

Kuroi Web Design and Development | Twitter

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

30 Jul 2007, 7:45 PM
#13
mjw2305 avatar

mjw2305

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: How do i make banner ads appear on the front page only?

Here is the change that i made

if (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) {

Changed to

if (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2) && $this_is_home_page) {

which gave me this error

Fatal error: Call to a member function on a non-object in /home/jane776/public_html/shop/includes/templates/template_default/common/tpl_main_page.php on line 102

Which appeared as the only text in the centre column (it stopped everything else in the centre column from appearing)

I have removed the modification now as the site is in its busy time of day, but i really do appriciate your perseverance with this - thanks alot

30 Jul 2007, 8:36 PM
#14
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: How do i make banner ads appear on the front page only?

This doesn't make sense. The code that you say you changed is in the Gloss Black or template_default tpl_header.php (you didn't say which you changed), but the error has been generated by your template_default tpl_main_page.php file.

Kuroi Web Design and Development | Twitter

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

30 Jul 2007, 9:39 PM
#15
mjw2305 avatar

mjw2305

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: How do i make banner ads appear on the front page only?

kuroi:

In default Zen Cart you would find the line in your tpl_main_page.php that is identical to the line to which I referred in my original post, except for referring to SET3 instead of SET2 and make the change that I recommended.

I changed the code for Header SET3 in template_default tpl_main_page.php file

SET3 doesn't appear in the tpl_header.php

Sorry for not saying which file earlier, but it would appear that the error does make sense given the changes i made

Kind Regards

30 Jul 2007, 9:48 PM
#16
mjw2305 avatar

mjw2305

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: How do i make banner ads appear on the front page only?

Sorry just realised you asked for the changes with a few lines either side of it so here it is

?>
<td valign="top">

<!-- bof breadcrumb --> <?php if (DEFINE_BREADCRUMB_STATUS == '1' || (DEFINE_BREADCRUMB_STATUS == '2' && !$this_is_home_page) ) { ?>
<div id="navBreadCrumb"><?php echo $breadcrumb->trail(BREAD_CRUMBS_SEPARATOR); ?></div>
<?php } ?> <!-- eof breadcrumb --> <?php if (SHOW_BANNERS_GROUP_SET3 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3)) { if ($banner->RecordCount() > 0) { ?> <div id="bannerThree" class="banners"><?php echo zen_display_banner('static', $banner); ?></div> <?php } } ?> <!-- bof upload alerts --> <?php if ($messageStack->size('upload') > 0) echo $messageStack->output('upload'); ?> <!-- eof upload alerts --> <?php /** * prepares and displays center column * */ require($body_code); ?>

I changed the section you instructed to this

if (SHOW_BANNERS_GROUP_SET3 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3) && $this_is_home_page) {

Kind Regards

1 Aug 2007, 11:53 AM
#17
mjw2305 avatar

mjw2305

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: How do i make banner ads appear on the front page only?

Any more ideas on what the problem might be Kuroi?

Or is there anyone else out there who has had this problem before?

Thanks in advance

1 Aug 2007, 10:21 PM
#18
mjw2305 avatar

mjw2305

New Zenner

Join Date:
Jul 2007
Posts:
17
Plugin Contributions:
0

Re: How do i make banner ads appear on the front page only?

Ok i have a little more information now i have been trying out a few different things.

IF I CHANGE

if (SHOW_BANNERS_GROUP_SET3 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3)) {

TO

if (SHOW_BANNERS_GROUP_SET3 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3) && $this_is_home_page) {

In the template_default tpl_main_page.php file, I get this error relating to the file i have changed

Fatal error: Call to a member function on a non-object

But the error is only present on the main page, all the other pages function perfectly without displaying the Header in SET3

As a test i did the same modification to SET2 in the tpl_header.php and had the same result - Main page wouldn't work but all the others were perfectly normal with the Header in SET2 missing just like it should be.

It appears that this added piece of code '&& $this_is_home_page' is performing as it should, in other words it is preventing the headers appearing outside the main page, but i can't seem to understand why the main page is displaying an error.

It seems that i am so close yet maybe not lol

I am trying to learn all i can about this error and its meaning, but i'm not getting anywhere fast

Does anyone out there know exactly what this error means

'Fatal error: Call to a member function on a non-object'

Many Thanks

Mat

2 Aug 2007, 12:06 AM
#19
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: How do i make banner ads appear on the front page only?

Sorry, to make clear to PHP exactly what we're doing, we need to modify that code very slightly to either> if (SHOW_BANNERS_GROUP_SET3 != '' && ($banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3)) && $this_is_home_page) {or my preferred version> if (SHOW_BANNERS_GROUP_SET3 != '' && $this_is_home_page && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3)) {But it should still be done in an over-ride file and not the template_default version.

Kuroi Web Design and Development | Twitter

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

2 Aug 2007, 12:54 AM
#20
aggiesoap avatar

aggiesoap

New Zenner

Join Date:
May 2007
Posts:
6
Plugin Contributions:
0

Re: How do i make banner ads appear on the front page only?

I've been following this thread as I want a banner only on the main page. I tried both changes that have been suggested, however the banner still shows on all pages. Is there something small I have overlooked? Another setting somewhere? I have the banner turned on in banner manager and all banners OFF in layout box controller.

Thanks!