Yii is great but assets is the thing that was always strange for me (since the 1.1 version).
I'm using Yii2 currently with Advanced app template. I want to register some css/js files in frontend main
layout view (trying to use HTML5UP Prologue Template).
How it can be done? I placed my css
files under frontend/web/css
directory, js
under frontend/web/js
and layout images under frontend/web/images
dir.
Under frontend/assets
directory I created PrologueAssets
class like this:
namespace frontend\assets;
use yii\web\AssetBundle;
class PrologueAssets extends AssetBundle {
public $sourcePath = "@webroot";
public $css = [
'css/skel.css',
'css/style.css',
'css/style-wide.css',
];
public $js = [
'js/jquery.min.js',
'js/jquery.scrolly.min.js',
'js/jquery.scrollzer.min.js',
'js/skel.min.js',
'js/skel-layers.min.js',
'js/init.js',
];
static function register($view) {
die(self::sourcePath);
parent::register($view);
}
}
Unfortunately none of these files are registered. How to do that?
Little second question - how to register css files only if eg IE8 or IE9 is detected?
AppAsset.php
(instead ofPrologueAssets.php
? - Prabowo Murtisite.css
is loaded properly. - JoeUrl::base()
to generate base url and by addingcss/...
orjs/...
to the end. I always thought assets are to complicated in Yii. - Joe