Zen Cart Logo
Forums / General Questions / log off link - how do I make it only appear when logged on?

log off link - how do I make it only appear when logged on?

Locked

Views: 2,961

Results 21 to 24 of 24
This thread is locked. New replies are disabled.
28 Mar 2008, 12:10 AM
#21
gsdcypher avatar

gsdcypher

Totally Zenned

Join Date:
Feb 2007
Posts:
816
Plugin Contributions:
0

log off link - how do I make it only appear when logged on?

hmmmm..... ok how about this code taken from orig tpl_header and placed in custom tpl_ezpages_bar_header.php. does this look right??? :huh:

 
  /**
   * require code to show EZ-Pages list
   */
  include(DIR_WS_MODULES . zen_get_module_directory('ezpages_bar_header.php'));
?>
<?php if (sizeof($var_linksList) >= 1) { ?>
<div id="navEZPagesTop">
   <div class="clearBoth"></div>
<!--bof-login, logoff, view cart and checkout now links-->   
<div id="ezLinks">
<ul class="forward">
    <li><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php echo HEADER_TITLE_CATALOG; ?></a></li>
<?php if ($_SESSION['customer_id']) { ?>
    <li><a href="<?php echo zen_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a></li>
    <li><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a></li>
<?php
      } else {
        if (STORE_STATUS == '0') {
?>
    <li><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a></li>
<?php } } ?>
<?php if ($_SESSION['cart']->count_contents() != 0) { ?>
    <li><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a></li>
    <li><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></li>
</ul>
</div>
<?php }?>
<!--eof-login, logoff, view cart and checkout now links--> 
<?php for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) {  ?>
  <a href="<?php echo $var_linksList[$i]['link']; ?>"><?php echo $var_linksList[$i]['name']; ?></a><?php echo ($i < $n ? EZPAGES_SEPARATOR_HEADER : '') . "\n"; ?>
<?php } // end FOR loop ?>
  </div>
<?php } ?>

thanks

28 Mar 2008, 12:56 AM
#22
gjh42 avatar

gjh42

Black Belt

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

Re: log off link - how do I make it only appear when logged on?

Mmm... I don't know if it would work, but at best there is no benefit to putting that code in tpl_ezpages_bar_header.php. Keep it in tpl_header.php, creating a new div like the navMainWrapper one, but named differently (like ezLinks). Place it in the file either just before or just after the ez-pages code block, depending on how you want it to display.

On brief examination, it seems like it should work as you have it.

28 Mar 2008, 1:56 AM
#23
gsdcypher avatar

gsdcypher

Totally Zenned

Join Date:
Feb 2007
Posts:
816
Plugin Contributions:
0

Re: log off link - how do I make it only appear when logged on?

The other code didn't work, so I went ahead and added this code to the ezpages_bar_header that you had originally wrote..... and it works like a charm! Great idea!!! :clap:

```

<?php for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) { if ($_SESSION['customer_id'] or ($var_linksList[$i]['name'] != 'Logoff')) { //show Logoff only if logged in ?>
<a href="<?php echo $var_linksList[$i]['link']; ?>"><?php echo $var_linksList[$i]['name']; ?></a><?php echo ($i < $n ? EZPAGES_SEPARATOR_HEADER : '') . "\n"; ?>

<?php } // /if } // end FOR loop ?>

</div>

1 Apr 2008, 11:28 PM
#24
gsdcypher avatar

gsdcypher

Totally Zenned

Join Date:
Feb 2007
Posts:
816
Plugin Contributions:
0

Re: log off link - how do I make it only appear when logged on?

Hey gjh42,

The code is working great in the header. But the footer is still "off." When you add an item to the cart, the view cart | checkout now links appear slightly below the other links rather than inline with them. Any ideas on why that might be happening?

Also is there a way we can have the links remain centered and have the view cart | checkout now links appear at the right without pushing the centered links over to the left???

Thanks.