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)
-   -   [solved] Show brands in menu dropdown (https://forum.x-cart.com/showthread.php?t=73947)

benlind 05-06-2016 09:26 AM

[solved] Show brands in menu dropdown
 
I have installed the "Show By Brand" module. I would like to list all of the site's brands in a dropdown menu in the navigation of every page. I added this code to the nav:

HTML Code:

<widget class="XLite\Module\QSL\ShopByBrand\View\BrandsBlock" limit="10000" />

That displays the brands correctly on the home page, but nowhere else. I know that the "BrandsBlock" widget is only meant to be used on the home page, which is probably why it is only showing up on the homepage. But I don't know how else to get all of the brands in a list on every page.

Please help!

totaltec 05-09-2016 09:52 PM

Re: Show brands in menu dropdown
 
Check the module for getAllowedTargets() method. Decorate the module to expand the allowed targets.

benlind 06-25-2016 04:34 PM

Re: Show brands in menu dropdown
 
I tried to decorate that method, but I can't figure out how to allow all targets. Is there a keyword to allow everything? If not, is there some list of all possible targets that I can use?

xplorer 06-26-2016 11:17 PM

Re: Show brands in menu dropdown
 
Returning an empty array in getAllowedTargets() will make the widget visible on all pages. I.e. you should do something like this:
PHP Code:

namespace XLite\Module\YOUR_DEV_ID\YOUR_MODULE_ID\View;

/**
 * @LC_Dependencies ("QSL\ShopByBrand")
 */
class BrandsBlock extends \XLite\Module\QSL\ShopByBrand\View\BrandsBlock implements \XLite\Base\IDecorator
{
    public static function 
getAllowedTargets()
    {
        return array();
    }



The @LC_Dependencies ("QSL\ShopByBrand") statement is here to make your code apply over the code added by Shop By Brand module (otherwise XC5 may run the original module's method after yours and this will ignore your modification).

benlind 06-28-2016 01:07 PM

Re: Show brands in menu dropdown
 
xplorer, that worked perfectly. Thank you!


All times are GMT -8. The time now is 08:21 PM.

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