a.ziaratban
(Abolfazl Ziaratban)
May 18, 2017, 12:17pm
1
hi
i need give all css and js url in a layout and i not want register.
How do i implement this scenario?
for example
view
use app\assets\Asset1;
use app\assets\Asset2;
Asset1::Register($this);
Asset2::Register($this);
output in header layout
<head>
<!-- css and js tag not registered -->
<script>
// manage by developer
var js = {
'http://example.com/parent.js' : {
'http://example.com/child.js' : {}, //this is dependency
}
};
var css = ['http://example.com/my_file1.css','http://example.com/my_file2.css'];
</script>
</head>
Register js file and register css file are both documented on that page.
[color="#303336 "][font=“inherit”][size=“2”]$this[/size][/font][/color][color="#303336 "][font=“inherit”][size=“2”]->[/size][/font][/color][color="#303336 "][font=“inherit”][size=“2”]registerJsFile[/size][/font][/color][color="#303336 "][font=“inherit”]size=“2” ;
[/size][/font][/color]
[color="#303336 "][font=“inherit”][size=“2”]$this[/size][/font][/color][color="#303336 "][font=“inherit”][size=“2”]->[/size][/font][/color][color="#303336 "][font=“inherit”][size=“2”]registerCssFile[/size][/font][/color][color="#303336 "][font=“inherit”]size=“2” ;[/size][/font][/color]
[color="#303336 "][font="inherit"] [/font][/color]
[color="#303336 "][font="inherit"][size="2"]If you want it to output like you have above you will need to make your own function to do so[/size][/font][/color]
a.ziaratban
(Abolfazl Ziaratban)
May 18, 2017, 2:32pm
3
skworden:
Register js file and register css file are both documented on that page.
[color="#303336 "][font=“inherit”][size=“2”]$this[/size][/font][/color][color="#303336 "][font=“inherit”][size=“2”]->[/size][/font][/color][color="#303336 "][font=“inherit”][size=“2”]registerJsFile[/size][/font][/color][color="#303336 "][font=“inherit”]size=“2” ;
[/size][/font][/color]
[color="#303336 "][font=“inherit”][size=“2”]$this[/size][/font][/color][color="#303336 "][font=“inherit”][size=“2”]->[/size][/font][/color][color="#303336 "][font=“inherit”][size=“2”]registerCssFile[/size][/font][/color][color="#303336 "][font=“inherit”]size=“2” ;[/size][/font][/color]
[color="#303336 "][font="inherit"] [/font][/color]
[color="#303336 "][font="inherit"][size="2"]If you want it to output like you have above you will need to make your own function to do so[/size][/font][/color]
no, actually i want use AssetBundle with output array of js & css url.
If the above doesn’t work you will need to make your own class to do this since assetBundels don’t output in that format.
a.ziaratban
(Abolfazl Ziaratban)
May 19, 2017, 1:46pm
5
thanks. i waiting this answer. but i think this feature must be added because how i can use Yii AssetBundle and fallback project ?
You have to write a plugin yourself that most likely would extend assetBundle.