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

Removing SimpleCMS primary_menu.css from CSS list

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 02-08-2017, 06:31 AM
 
xgarb xgarb is online now
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default 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?
__________________
Core version: 5.5.xx
Reply With Quote
  #2  
Old 02-09-2017, 05:43 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
xgarb (02-10-2017)
  #3  
Old 02-10-2017, 07:35 AM
 
xgarb xgarb is online now
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default 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.
__________________
Core version: 5.5.xx
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 02:29 AM.

   

 
X-Cart forums © 2001-2020