Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

this.isCheckoutLayout() to also hide on view cart

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 01-20-2017, 01:43 PM
 
info@shadowgraphicsinc.co info@shadowgraphicsinc.co is offline
 

Senior Member
  
Join Date: Jan 2011
Posts: 123
 

Default this.isCheckoutLayout() to also hide on view cart

I have also been searching the forums but to no avail with this as well.

We have a menu on our site that is shown on all pages - but we would not like them shown on view cart AND checkout.

I found that using this

PHP Code:
{% if not this.isCheckoutLayout() %} 

works to hide everything from the final check out, but we were also looking to hide everything from the view cart page as well.

Any info on what the correct code would be for that?

thanks!
Reply With Quote
  #2  
Old 01-25-2017, 12:39 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: this.isCheckoutLayout() to also hide on view cart

To check if it is the cart page you can use the following code in your View class:
PHP Code:
/**
     * Check if the widget is visible.
     *
     * @return boolean
     */
    
protected function isVisible()
    {
        return 
parent::isVisible() && $this->isAllowedPage();
    }

    protected function 
isAllowedPage()
    {
        
$controller = \XLite::getController();

        return !
$controller->isCheckoutLayout() && ($controller->getTarget() !== 'cart');
    } 

This way you don't need any checks in the template of your menu widget - isVisible() method will make it disappear on checkout and cart pages.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:17 PM.

   

 
X-Cart forums © 2001-2020