If this is your first visit, check our documentation. To post, register or login.

Change banner if user is logged in?

Started by kendog819 on 30 Oct 2011, 12:19 AM · Views: 716

Results 1 to 5 of 5
30 Oct 2011, 12:19 AM
#1
kendog819 avatar

kendog819

New Zenner

Join Date:
Oct 2011
Posts:
16
Plugin Contributions:
0

Post #1 by kendog819

I have a banner (header1) that instructs users to "register now to receive 10% off of their 1st order" . It obviously doesn't need to be displayed if they are logged in.

Is there a way of only having the banner being displayed if the user hasn't logged in, and display something else if they have?

Thanks,
Ken

30 Oct 2011, 12:42 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #2 by kobra

Create a custom - for your template - tpl_main_page.php file
Reference the comments in that file

Zen-Venom Get Bitten

30 Oct 2011, 1:22 AM
#3
kendog819 avatar

kendog819

New Zenner

Join Date:
Oct 2011
Posts:
16
Plugin Contributions:
0

Post #3 by kendog819

I was able to remove the banner if the user is logged in, checking the session for customer id, now i want to have a set of logged in banners and non logged in banners, i don't understand how to change the banner being displayed rather than just not showing it at all, can you help me?

Thanks,
Ken

30 Oct 2011, 2:04 AM
#4
ajeh avatar

ajeh

Oba-san

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

Post #4 by ajeh

In the tpl_main_page.php ... customize the code from:

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

to read:

<?php
  if ($_SESSION['customer_id'] && 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
  define('SHOW_BANNERS_GROUP_SET1_GUEST', 'GUEST');
  if (!$_SESSION['customer_id'] && SHOW_BANNERS_GROUP_SET1_GUEST != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET1_GUEST)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerOne" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }
?>

Now add a Banner to the Banner Group name:
GUEST

and a Banner to the Banner Group name:
CUSTOMER

In the Configuration ... Layout Settings ... set the Header 1 to have the Banner Group of:
CUSTOMER

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!

30 Oct 2011, 2:29 AM
#5
kendog819 avatar

kendog819

New Zenner

Join Date:
Oct 2011
Posts:
16
Plugin Contributions:
0

Post #5 by kendog819

Thanks Ajeh,

I actually had a friend help me figure it out, in a pretty similar way.

I was hoping you would also help me on my other open post i have in the "Creating Discounts...." forum.

Thanks Again,
Ken