Yii Framework Forum: how i can manage asset register in a layout? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

how i can manage asset register in a layout?

#1 User is offline   a.ziaratban 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 12-January 16

Posted 18 May 2017 - 07:17 AM

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>

0

#2 User is offline   skworden 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 516
  • Joined: 14-June 12
  • Location:Virginia, USA

Posted 18 May 2017 - 09:03 AM

Register js file and register css file are both documented on that page.


$this->registerJsFile('http://example.com/parent.js');

$this->registerCssFile('http://example.com/parent.css');

If you want it to output like you have above you will need to make your own function to do so
0

#3 User is offline   a.ziaratban 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 12-January 16

Posted 18 May 2017 - 09:32 AM

View Postskworden, on 18 May 2017 - 09:03 AM, said:

Register js file and register css file are both documented on that page.


$this->registerJsFile('http://example.com/parent.js');

$this->registerCssFile('http://example.com/parent.css');

If you want it to output like you have above you will need to make your own function to do so


no, actually i want use AssetBundle with output array of js & css url.
0

#4 User is offline   skworden 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 516
  • Joined: 14-June 12
  • Location:Virginia, USA

Posted 18 May 2017 - 09:51 PM

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.
1

#5 User is offline   a.ziaratban 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 12-January 16

Posted 19 May 2017 - 08:46 AM

View Postskworden, on 18 May 2017 - 09:51 PM, said:

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.

thanks. i waiting this answer. but i think this feature must be added because how i can use Yii AssetBundle and fallback project ?
0

#6 User is offline   skworden 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 516
  • Joined: 14-June 12
  • Location:Virginia, USA

Posted 19 May 2017 - 04:34 PM

You have to write a plugin yourself that most likely would extend assetBundle.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users