X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   this.isCheckoutLayout() to also hide on view cart (https://forum.x-cart.com/showthread.php?t=74887)

info@shadowgraphicsinc.co 01-20-2017 01:43 PM

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!

qualiteam 01-25-2017 12:39 AM

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.


All times are GMT -8. The time now is 05:55 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.