Last active
October 28, 2016 00:41
-
-
Save YuzuruSano/e5d502846c0f65008140 to your computer and use it in GitHub Desktop.
concrete5 5.7 自身で定義したjsやcssをグルーピングして読み込み
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* =============================================== | |
@application/bootstrap/app.php | |
jsはapplication/jsへ | |
cssはapplication/cssへ | |
=============================================== */ | |
$al = AssetList::getInstance(); | |
$al->register( | |
'css', | |
'my_css_handle', | |
'css/my_css.css', | |
array() | |
); | |
$al->register( | |
'javascript', | |
'my_js_handle', | |
'js/my.js', | |
array(//色々オプション指定 詳しく調べてない・・・ | |
'version' => '1.0.0', | |
'position' => \Concrete\Core\Asset\Asset::ASSET_POSITION_FOOTER, | |
'minify' => false, | |
'combine' => true | |
), | |
'package_handle'//パッケージのon_startで定義するときはpackage_handleを指定する | |
); | |
$al->registerGroup('my_asset_group', array( | |
array('javascript', 'my_js_handle'), | |
array('css', 'my_css_handle') | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* =============================================== | |
いろんなコントローラーで呼びだせる | |
=============================================== */ | |
public function form() | |
{ | |
$this->load(); | |
$this->requireAsset('my_asset_group'); | |
} | |
//とか。viewでも呼べる | |
$v = \View::getInstance(); | |
$v->requireAsset('my_asset_group'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment