AbanteCart Community

AbanteCart Development => Customization help => Topic started by: JHammond53 on October 16, 2014, 11:21:41 AM

Title: Hiding certain elements when not logged in
Post by: JHammond53 on October 16, 2014, 11:21:41 AM
Ok, this may be quite complicated. If someone is not logged in, I would like to hide the entire top menu except for login. I would also like to hide the cart just below the top menu. One other thing is featured items.

If someone is then logged in, all of these would reappear.

I am not afraid of changing code as I have changed some already. Just can't find the right files/code to implement.
Title: Re: Hiding certain elements when not logged in
Post by: abantecart on October 18, 2014, 08:42:53 PM
You can use be below condition in header.tpl file

Code: [Select]
if (!$this->customer->isLogged()) {
...
}
Title: Re: Hiding certain elements when not logged in
Post by: JHammond53 on October 20, 2014, 02:49:42 PM
You can use be below condition in header.tpl file

Code: [Select]
if (!$this->customer->isLogged()) {
...
}

Thanks for the response. I have used this to remove the cart beneath the top menu, however the top menu is displayed as ($children_blocks[2]) not sure how to pick apart what I want to show when not logged in.
Title: Re: Hiding certain elements when not logged in
Post by: JHammond53 on October 21, 2014, 10:56:14 AM
Well I figured it out. It may not be the best way to do it, but I got it done.
Title: Re: Hiding certain elements when not logged in
Post by: abantecart on October 22, 2014, 12:11:59 PM
Can you share with others?
Title: Re: Hiding certain elements when not logged in
Post by: JHammond53 on October 31, 2014, 02:25:18 PM
I modified the header.tpl file to read as such. Anything in red is what I added. You can see it in action at archmetalsfl.com

Quote
<div class="headerstrip_blocks">

                  <div class="pull-left ml10"><?php echo ${$children_blocks[0]}; ?></div>

                  <div class="pull-left"><?php echo ${$children_blocks[1]}; ?></div>

                  <div class="pull-left">
                     <?php if ($this->customer->isLogged()) {   ?>                     
                     <?php echo ${$children_blocks[2]}; ?>
                  <?php } else {   ?>
                  <div class="navbar" id="topnav">
                      <div class="navbar-inner">
                     <ul id="main_menu_top" class="nav main_menu">
                     <li  data-id="menu_login"  class="dropdown hover"><a  class="top menu_login"  href="http://www.archmetalsfl.com/index.php?rt=account/login" ><span class="menu_text">Login</span></a></li>                  
                     </ul>
                     </div>
                     </div>
                  <?php } ?>                  
                  </div>
Title: Re: Hiding certain elements when not logged in
Post by: abantecart on November 03, 2014, 04:55:50 PM
Thank you