Author Topic: Hiding certain elements when not logged in  (Read 6373 times)

Offline JHammond53

  • Newbie
  • *
  • Posts: 39
  • Karma: +11/-0
    • View Profile
Hiding certain elements when not logged in
« 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.
« Last Edit: October 16, 2014, 11:27:00 AM by JHammond53 »

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Hiding certain elements when not logged in
« Reply #1 on: October 18, 2014, 08:42:53 PM »
You can use be below condition in header.tpl file

Code: [Select]
if (!$this->customer->isLogged()) {
...
}
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline JHammond53

  • Newbie
  • *
  • Posts: 39
  • Karma: +11/-0
    • View Profile
Re: Hiding certain elements when not logged in
« Reply #2 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.

Offline JHammond53

  • Newbie
  • *
  • Posts: 39
  • Karma: +11/-0
    • View Profile
Re: Hiding certain elements when not logged in
« Reply #3 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.

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Hiding certain elements when not logged in
« Reply #4 on: October 22, 2014, 12:11:59 PM »
Can you share with others?
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline JHammond53

  • Newbie
  • *
  • Posts: 39
  • Karma: +11/-0
    • View Profile
Re: Hiding certain elements when not logged in
« Reply #5 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>
« Last Edit: October 31, 2014, 02:26:49 PM by JHammond53 »

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Hiding certain elements when not logged in
« Reply #6 on: November 03, 2014, 04:55:50 PM »
Thank you
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

 

Powered by SMFPacks Social Login Mod