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)
-   -   Remove featured products from all pages except home page (https://forum.x-cart.com/showthread.php?t=74695)

jack68938 11-21-2016 01:43 PM

Remove featured products from all pages except home page
 
I have tried to remove the featured products section from all pages except the home page. I tried removing it from all pages as well, with no luck.

Here is what i have in my custom module Main.php:

PHP Code:

// Remove this weeks big secrets from category pages
\XLite\Core\Layout::getInstance()->removeTemplateFromList('default/en/common/dialog.tpl''center.bottom'); 


Not sure where I am going wrong. Any help would be greatly appreciated.

Thanks!

qualiteam 11-21-2016 09:26 PM

Re: Remove featured products from all pages except home page
 
You try to remove one of core templates that is used in multiple places. This is wrong.

Instead, you should create a custom module that "decorates" the getAllowedTargets() method in \XLite\Module\CDev\FeaturedProducts\View\Customer\ FeaturedProducts class as follows:
PHP Code:

// ...
    /**
     * Return list of targets allowed for this widget
     *
     * @return array
     */
    
public static function getAllowedTargets()
    {
        return array(
'main');
    }
// ... 


This will make the widget appear on pages rendered by the "main" controller only - and this controller renders only the home page.

jack68938 11-22-2016 08:33 AM

Re: Remove featured products from all pages except home page
 
thank you. That worked!


All times are GMT -8. The time now is 02:00 AM.

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