CSS Asset Loading (5.7.3)
Permalink
Hello!
Currently i´am developing a new Theme for 5.7.
I want to load the CSS files with the (AssetList::getInstance())->register() Method.
I have this Code in the on_start() routine in my Package Controller
This works and outputs:
Problem: In my case i need the media="screen" attribute but i cant find a way to change the value.
---------------------
My second Problem are files that only loads for IE. For example:
I can not find a solution for adding this files with that method. My first Idea:
How can i add css files with the media screen attribute and wrapps it in <!--[if lte IE 8]> and <![endif]--> ??????
greeting Johnny
Currently i´am developing a new Theme for 5.7.
I want to load the CSS files with the (AssetList::getInstance())->register() Method.
I have this Code in the on_start() routine in my Package Controller
(($cdn['load_from_cdn']) ? $al->register('css', 'owlcarousel', '//cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.2/owl.carousel.min.css', array('position'=>Asset::ASSET_POSITION_HEADER, 'local' => false, 'version' => '1.3.2'), $this) : $al->register('css', 'owlcarousel', 'themes/porto/vendor/owlcarousel/owl.carousel.css', array('position'=>Asset::ASSET_POSITION_HEADER, 'local' => true, 'version' => '1.3.2'), $this));
This works and outputs:
<link href="//cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.2/owl.carousel.min.css" rel="stylesheet" type="text/css" media="all">
Problem: In my case i need the media="screen" attribute but i cant find a way to change the value.
---------------------
My second Problem are files that only loads for IE. For example:
<!--[if lte IE 8]> <script src="/5.7.3/packages/porto/themes/porto/vendor/respond/respond.js"></script> <![endif]-->
I can not find a solution for adding this files with that method. My first Idea:
$al->register('css', '....', '....', array(......, 'css_wrapper'=>'lte IE 8', 'media'=>'screen'), $this));
How can i add css files with the media screen attribute and wrapps it in <!--[if lte IE 8]> and <![endif]--> ??????
greeting Johnny
So I think if you need costum your output you need to create new Asset Type in your package. If you just develop the theme (not in package) maybe the best practice is by write manually your asset output
Maybe read register function under AssetList class will give you idea also. See that on this path /concrete/src/Asset/AssetList.php