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)
-   -   Best way to add additional css file to custom theme (https://forum.x-cart.com/showthread.php?t=70389)

spdesign 10-31-2014 09:22 AM

Best way to add additional css file to custom theme
 
Looking for the most efficient way to add a css file to a custom theme and have it load LAST in X-Cart 5.x

I realize I could hard code a link to it into a .tpl file, but there's probably a better way to handle it to take advantage of aggregating/minifying that X-Cart 5 does.

spdesign 10-31-2014 10:14 AM

Re: Best way to add additional css file to custom theme
 
For 5.1.7:

Figured it out. Follow instructions in KB here: http://kb.x-cart.com/display/XDD/Step+2+-+applying+design+changes

except with the following changes if your custom theme is a module.

In your module directory (classes/XLite/YourName/YourThemeName/View/) create AView.php with the following code

Code:

<?php
 
namespace XLite\Module\YourName\YourThemeName\View;
 
class AView extends \XLite\View\AView implements \XLite\Base\IDecorator
{
    public function getCSSFiles()
    {
        $list = parent::getCSSFiles();
 
        $list[] = 'css/yourcssfile.css';
 
        return $list;
    } 
}


And then make sure yourcssfile.css is in /skins/YourThemeName/default/en/css/

Probably pretty basic and unnecessary, but just in case others are less experienced with XCart 5 like me and need it really spelled out.

cflsystems 10-31-2014 10:28 AM

Re: Best way to add additional css file to custom theme
 
This is how you do it but keep in mind this will not make the file to load last. So you should use classes names as unique as possible.

If "YourName" from above is "spdesign" and you have another module with "YourName" being "thespdesign" loading another css file their css file will load after yours.

spdesign 10-31-2014 10:32 AM

Re: Best way to add additional css file to custom theme
 
Thank you for that clarification. That will be helpful in future.

tony_sologubov 11-03-2014 04:12 AM

Re: Best way to add additional css file to custom theme
 
I would not rely on module's name in order to be last. If you want to be after certain CSS file, then use sorting option or depend on the module:
http://kb.x-cart.com/display/XDD/Making+one+module+depend+on+another


All times are GMT -8. The time now is 02:49 PM.

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