Skip to content

Instantly share code, notes, and snippets.

@YuzuruSano
Last active October 28, 2016 00:41
Show Gist options
  • Save YuzuruSano/e5d502846c0f65008140 to your computer and use it in GitHub Desktop.
Save YuzuruSano/e5d502846c0f65008140 to your computer and use it in GitHub Desktop.
concrete5 5.7 自身で定義したjsやcssをグルーピングして読み込み
<?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')
));
<?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