Zen Cart Logo
Forums / Basic Configuration / Dynamic Sidebox Content Based on Login Status

Dynamic Sidebox Content Based on Login Status

Locked

Views: 1,427

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
9 Nov 2009, 3:28 PM
#1
stanbridge avatar

stanbridge

New Zenner

Join Date:
Feb 2009
Posts:
25
Plugin Contributions:
0

Dynamic Sidebox Content Based on Login Status

Hi all,

I have an image+href sitting in a sidebox. I want the image+href to be set a certain way if the user is currently logged in, and another way if the user is not currently logged in.

I found some code from other similar forum posts and have adapted my code as below.

if($_GET['id'] == xx and !$_SESSION['customer_id']) {
$content = "<div style=\"   width:161px; background-color:#FFFFFF; padding:5px; border:2px solid #C7A88B; margin-top:8px;     \"><a href=\"http://mywebsite.com.au/shop/index.php?main_page=login\"><img src=\"images/squirrel02/squirrel-login.jpg\"></a></div>                 ";
} else {
$content = "<div style=\"   width:161px; background-color:#FFFFFF; padding:5px; border:2px solid #C7A88B; margin-top:8px;     \"><a href=\"http://mywebsite.com.au/shop/index.php?main_page=logoff\"><img src=\"images/squirrel02/squirrel-logout.jpg\"></a></div>                 ";
}

The problem with this method is, it always defaults to the second option. Can somebody show me what I'm doing wrong?

Many thanks,

Standbridge

9 Nov 2009, 3:42 PM
#2
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Dynamic Sidebox Content Based on Login Status

The if statement might read:

if(isset($_SESSION['customer_id'])){
//display logged in version
}else{
//display not logged in version
}

there is something quite different happening with the get parameter.

10 Nov 2009, 10:04 AM
#3
stanbridge avatar

stanbridge

New Zenner

Join Date:
Feb 2009
Posts:
25
Plugin Contributions:
0

Re: Dynamic Sidebox Content Based on Login Status

Bloody fantastic Nick!
:clap:
Works a treat, many thanks!

Cheers,

Chris