Forums / Templates, Stylesheets, Page Layout / Showing banners just on login page

Showing banners just on login page

Locked

Views: 2,553

Results 1 to 17 of 17
This thread is locked. New replies are disabled.
30 Apr 2010, 2:49 PM
#1
shalesey avatar

shalesey

New Zenner

Join Date:
Feb 2010
Posts:
58
Plugin Contributions:
0

Showing banners just on login page

Is there any way to show banners just on the login page?

Similar to the below code to just show banners on the home page.

<?php if ($this_is_home_page) { ?>  

<?php
  if (SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }
?>

<div id="headerpic">
<?php
              if (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) {
                if ($banner->RecordCount() > 0) {
?>
      <div id="bannerTwo" class="banners"><?php echo zen_display_banner('static', $banner);?></div>
	  
	 <?php } } ?>
</div>







<?php } ?> 
30 Apr 2010, 3:22 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Showing banners just on login page

You can use the $this_is_home_page for anything ...

if ($this_is_home_page) {

You can use that for any code ... if there is already an IF statement just surround the original IF with the $this_is_home_page IF statement ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 May 2010, 8:47 AM
#3
shalesey avatar

shalesey

New Zenner

Join Date:
Feb 2010
Posts:
58
Plugin Contributions:
0

Re: Showing banners just on login page

I'm not sure that you answered my question. The question is as follows : -

Is there a way to make things, such as banners, only appear on the login page? Similar to the code I posted where you can make things appear on the homepage.

4 May 2010, 2:01 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Showing banners just on login page

In a word ... no ... :blink:

I surely did not answer your question correctly ... so let me try that again ...

You can use:

if ($_GET['main_page'] == FILENAME_LOGIN) {
  // do this
} else {
  // do that 
}

see if that helps you better now that I am paying attention ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 May 2010, 3:46 PM
#5
shalesey avatar

shalesey

New Zenner

Join Date:
Feb 2010
Posts:
58
Plugin Contributions:
0

Re: Showing banners just on login page

Ok I have to admit that i've never coded PHP in my life and i'm mumbling this together from what i'm working out.

I've had a go below. Can you tell me if this is how it should look for showing banner 1 on the login page and banner 2 on all other pages?

<?php
	if ($_GET['main_page'] == FILENAME_LOGIN) {
if (SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }
?>
} else {
  <?php
              if (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) {
                if ($banner->RecordCount() > 0) {
?>
      <div id="bannerTwo" class="banners"><?php echo zen_display_banner('static', $banner);?></div>
	  
	 <?php } } ?>
}
4 May 2010, 5:26 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Showing banners just on login page

Looking at the original code it would be easier to do this with change the code:

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

To read:

  if ($_GET['main_page'] == FILENAME_LOGIN && SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

5 May 2010, 9:12 AM
#7
shalesey avatar

shalesey

New Zenner

Join Date:
Feb 2010
Posts:
58
Plugin Contributions:
0

Re: Showing banners just on login page

Ok, is this what i'm looking for then?

<?php if ($this_is_home_page) { ?>  

<?php
  if ($_GET['main_page'] == FILENAME_LOGIN && SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }
?>

<div id="headerpic">
<?php
              if ($_GET['main_page'] == FILENAME_LOGIN && SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) {
                if ($banner->RecordCount() > 0) {
?>
      <div id="bannerTwo" class="banners"><?php echo zen_display_banner('static', $banner);?></div>
	  
	 <?php } } ?>
</div>

<?php } ?>
5 May 2010, 2:16 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Showing banners just on login page

What is the:

<?php if ($this_is_home_page) { ?>  
// stuff here 


<?php } ?>

in there for?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

5 May 2010, 4:01 PM
#9
shalesey avatar

shalesey

New Zenner

Join Date:
Feb 2010
Posts:
58
Plugin Contributions:
0

Re: Showing banners just on login page

Beacuse I don't know what i'm doing? :)

5 May 2010, 4:04 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Showing banners just on login page

Okay you don't need the test for the $this_is_main_page ... just the test for the login page, example:

  if ($_GET['main_page'] == FILENAME_LOGIN && SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 May 2010, 9:57 AM
#11
shalesey avatar

shalesey

New Zenner

Join Date:
Feb 2010
Posts:
58
Plugin Contributions:
0

Re: Showing banners just on login page

Thank you for all your help. One final question. If I was to specify that banner 1 be shown just on the login page and home page and banner 2 on every other page. Would it look like the below?

Crosses fingers

<?php
  if ($_GET['main_page'] == FILENAME_LOGIN && SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }
?>

<?php
  if( ($this_is_home_page) && SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }
?>

<div id="headerpic">
<?php
              if ($_GET['main_page'] == FILENAME_LOGIN && SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) {
                if ($banner->RecordCount() > 0) {
?>
      <div id="bannerTwo" class="banners"><?php echo zen_display_banner('static', $banner);?></div>
	  
	 <?php } } ?>
</div>
6 May 2010, 2:04 PM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Showing banners just on login page

If you want banner2 on every page, you do not want to set the reference to the login page on that:
$_GET['main_page'] == FILENAME_LOGIN &&

as that is making it only show on the login page ...

On the banner1 to show on home page and login page, you can do two IF statements as you have done it or you can reference both in the same IF using:
($_GET['main_page'] == FILENAME_LOGIN || $this_is_home_page) &&

where you have:
$_GET['main_page'] == FILENAME_LOGIN &&

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 May 2010, 3:13 PM
#13
shalesey avatar

shalesey

New Zenner

Join Date:
Feb 2010
Posts:
58
Plugin Contributions:
0

Re: Showing banners just on login page

OK, I want Banner 1 on homepage or login and banner 2 on every page other than those 2 pages.

Am I close?

<?php
  if ($_GET['main_page'] == FILENAME_LOGIN || $this_is_home_page) && SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {
    if ($banner->RecordCount() > 0) {
		<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
} else { SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) {
                if ($banner->RecordCount() > 0) {
		<div id="bannerTwo" class="banners"><?php echo zen_display_banner('static', $banner);?></div>
	  ?>
6 May 2010, 4:56 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Showing banners just on login page

Banner 1 code to show on login page and home page:

<?php
  if (($_GET['main_page'] == FILENAME_LOGIN || $this_is_home_page) && SHOW_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }
?>

Banner 2 code to not show on login page or home page

<?php
              if (($_GET['main_page'] != FILENAME_LOGIN && !this_is_home_page) && SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) {
                if ($banner->RecordCount() > 0) {
?>
      <div id="bannerTwo" class="banners"><?php echo zen_display_banner('static', $banner);?></div>
	  
	 <?php } } ?>

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

7 May 2010, 8:06 AM
#15
shalesey avatar

shalesey

New Zenner

Join Date:
Feb 2010
Posts:
58
Plugin Contributions:
0

Re: Showing banners just on login page

Ok the code is not quite working.

If I use the below I get banner 2 and 3 on the login and home page and banner 3 on every other page.

<div id="headerpic">
<?php
  if (($_GET['main_page'] == FILENAME_LOGIN || $this_is_home_page) && SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerTwo" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }
?>
</div>

<?php
              if (($_GET['main_page'] != FILENAME_LOGIN && !this_is_home_page) && 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 } } ?>


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

If I use the below code I get banner 2 on the login and homepage and banner 3 on no pages.

<div id="headerpic">
<?php
  if (($_GET['main_page'] == FILENAME_LOGIN || $this_is_home_page) && SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerTwo" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }
?>
</div>


<?php
              if (($_GET['main_page'] != FILENAME_LOGIN && !this_is_home_page) && 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 } } ?>

To be clear I want banner 2 on the login and home page and banner 3 on every page other than those two pages.

7 May 2010, 3:55 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Showing banners just on login page

That is because of the silly little typo in my code that you did not catch ... :eek:

Change the:
!this_is_home_page

to be:
!$this_is_home_page

It will work loads better ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

10 May 2010, 8:04 AM
#17
shalesey avatar

shalesey

New Zenner

Join Date:
Feb 2010
Posts:
58
Plugin Contributions:
0

Re: Showing banners just on login page

Yup that's got it. Thanks for all your help. :)