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)
-   -   Removing SimpleCMS primary_menu.css from CSS list (https://forum.x-cart.com/showthread.php?t=74982)

xgarb 02-08-2017 06:31 AM

Removing SimpleCMS primary_menu.css from CSS list
 
I've got my own menu that works entirely using the SimpleCMS top menu system but with all changes made using CSS.

I've put this CSS file in a module so it can be switched on and off easily.

What I now want to do is prevent the original CSS file being added to the list.

I've tried everything I've seen in tutorials and documentation but can't seem to stop it being added to the list.

What will work?

totaltec 02-09-2017 05:43 AM

Re: Removing SimpleCMS primary_menu.css from CSS list
 
You need to loop through the CSS files in your module, and remove the one you want. Your module will probably need to be dependent on the Simple CMS module.
PHP Code:

/**
     * Get a list of CSS files required to display the widget properly
     *
     * @return array
     */
    
public function getCSSFiles()
    {
        
$list parent::getCSSFiles();

        foreach (
$list as $key => $css_file) {
            if (
$css_file == 'this-one-css-file.css') {
               unset(
$list[$key]);
            }
        }

        return 
$list;
    } 

This code above is untested, just an example.

xgarb 02-10-2017 07:35 AM

Re: Removing SimpleCMS primary_menu.css from CSS list
 
I got it working with this:
Code:

namespace XLite\Module\ZZZTEST\ZtestRemoveCss;

/**
 *
 * @Decorator\Depend({"CDev\SimpleCMS"}),
 */


class Top extends \XLite\View\Menu\Customer\Top implements \XLite\Base\IDecorator
{

    /**
    * Return the CSS files for the menu
    *
    * @return array
    */
    public function getCSSFiles()
    {
       
        $list = parent::getCSSFiles();
               
                foreach ($list as $key => $css_file) {
            if ($css_file == 'modules/CDev/SimpleCMS/css/primary_menu.css') {
              unset($list[$key]);
            }
        }
                       
        return $list;
    }

}



You can see it working before and after in the debug
Code:

[15:32:28.000000] array (
  0 =>
  array (
    'file' => 'css/style.less',
    'media' => 'screen',
    'merge' => 'bootstrap/css/bootstrap.less',
  ),
  1 => 'modules/CDev/SocialLogin/style.css',
  2 => 'modules/CDev/Sale/css/lc.css',
  3 => 'modules/CDev/Paypal/style.css',
  4 =>
  array (
    'file' => 'modules/CDev/Paypal/style.less',
    'media' => 'screen',
    'merge' => 'bootstrap/css/bootstrap.less',
  ),
  5 => 'modules/CDev/SimpleCMS/css/primary_menu.css',
)
Runtime id: fca9e552e9db6c00b881ade23b2ba653
SAPI: fpm-fcgi; IP: 213.143.60.121
URI: /x53-upgrade-test1/x835-pk.html
Method: GET

[15:32:28.000000] array (
  0 =>
  array (
    'file' => 'css/style.less',
    'media' => 'screen',
    'merge' => 'bootstrap/css/bootstrap.less',
  ),
  1 => 'modules/CDev/SocialLogin/style.css',
  2 => 'modules/CDev/Sale/css/lc.css',
  3 => 'modules/CDev/Paypal/style.css',
  4 =>
  array (
    'file' => 'modules/CDev/Paypal/style.less',
    'media' => 'screen',
    'merge' => 'bootstrap/css/bootstrap.less',
  ),
)


It's always a problem for me working what and how to override methods but at least it's working now.


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

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