-
Notifications
You must be signed in to change notification settings - Fork 2
File
Note: Before you continue, I suggest you to read the Component and Section wiki pages.
// Syntax
'component-id' => [
// ...
'section1' => [
/* files goes here
--------------------
*/
# 1. As a string with or without / at beginning
'somefile.ext',
# 2. As an array (very first element without a key)
['dir/somefile2.ext']
# 3. As an array with properties (First element should be a filename and without a key)
['dir/somefile3.ext', '@property'=>'mixed-value']
//...
],
// other sections and their files
]string
Unique ID of the file. A valid name contains [a-z][a-zA-Z-0-9]+. By default each file will be generated with an automatic uinque id. This property will override the automatic generated file id.
Automatic generated id starts with
*char.
// Example
'section' => [
// ...
['icons/font-awesome-min.css', '@id'=>'main']
// ...
]string
That file url used to be in a production environment. When the
YII2CD_OFFLINEset to false. That@cdnfile path will be used in the place of main file path. (see Force using offline files )
Value starts with http/https or // will use as it is.
// Example
'section' => [
// ...
// Example 1: (leave it to the protocol[http or https])
['icons/font-awesome-min.css', '@cdn'=>'//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css']
// Example 2: (http only)
['icons/font-awesome.css', '@cdn'=>'http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css']
// Example 3: (https only)
['icons/font-awesome.css', '@cdn'=>'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css']
// Example 4: (minified version)
['icons/font-awesome.css', '@cdn'=>'/icons/font-awesome-min.css']
// ...
]boolean
Use this file as offline only. When the
YII2CD_OFFLINEset to false, it will be skipped. (see Force using offline files )
// Example
'section' => [
// ...
['icons/font-awesome-min.css', '@offline'=>true]
// ...
]array
A
Key=>Valuepair of array as$options.
(see the
$optionsparameter ofregisterJsFile($url, $options = [])andregisterCssFile($url, $options = [])method in a \yii\web\View class.
// Example
'section' => [
// ...
['icons/font-awesome-min.css', '@options'=> [
// The HTML attributes for the link tag goes here ...
]]
// ...
]mixed
A
key=>valuepair of an array wherekeystarts without@char andvaluecan be amixedvalue.
// Example
'font-awesome' => [
// ...
'css' => [
// ...
['icons/font-awesome-min.css', '@id'=>'libmain', 'attribute'=>'value']
// ...
],
// ...
],/** @var \yii2cdn\File $file */
$file = \Yii::$app->cdn->getFileByRoot('font-awesome/css/libmain');
// Get attribute value
echo $file->getAttr('attribute');
// output: value
// Update/Set attribute
echo $file->setAttr('attribute', 'value');
// output: value
// Get all the attributes
print_r ( $file->getAttributes() );boolean (Default value: true)
Disable the registering of this file (for CSS and JavaScript files only)
// Example
'font-awesome' => [
// ...
'css' => [
// ...
['icons/font-awesome-min.css',
// Set false to disable registring file as asset.
'registrable'=>false
]
// ...
],
// ...
],boolean (Default value: false)
Appends file modified time at the end of url. (for CSS and JavaScript no-cdn files only)
// Example
'font-awesome' => [
// ...
'css' => [
// ...
['icons/font-awesome-min.css',
// output url: ...file.js?v=############
'timestamp'=>true
]
// ...
],
// ...
],These variables starts with
@chars and place inside the file name (inside of a string/array's first element. See advance usage on Config Structure wiki page.
* = string
Append a url at the beginning of filename.
// Example
'section' => [
// ...
// Example 1: (In a string)
'@url(http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0)/css/font-awesome.min.css'
// output: http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css
// Example 2: (Or inside of array's element)
['@url(http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0)/css/font-awesome.min.css'],
// output: http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css
// ...
]string
Base Url
baseUrlproperty of the [cdn](How to use Yii2cdn#ii-add-a-component) component defined in a@app/config/main.php.
// Example
'font-awesome' => [
// ...
'css' => [
// ...
'@baseUrl/font-awesome/icons/font-awesome-min.css'],
// output: /cdn/font-awesome/icons/font-awesome-min.css
// ...
],
// ...
],string
Base Url of it's component.
// Example
'font-awesome' => [
// ...
'css' => [
// ...
'@thisComponentUrl/font-awesome-min.css',
// output: /cdn/font-awesome/font-awesome-min.css
// ...
],
// ...
],string
Base Url of it's section.
// Example
'font-awesome' => [
// ...
'css' => [
// ...
'@thisSectionUrl/font-awesome-min.css',
// output: /cdn/font-awesome/css/font-awesome-min.css
// ...
],
// ...
],component-id = string ID of the component.
Append a cdn component's url at the beginning of filename.
// Example
'bootstrap' => [
// ...
'css' => [
// ...
'css/bootstrap-min.css'
// ...
],
// ...
],
'font-awesome' => [
// ...
'css' => [
// ...
'icons/font-awesome-min.css',
// Include `bootstrap` component's base url
'@componentUrl(bootstrap)/css/bootstrap-min.css',
// output: /cdn/bootstrap/css/bootstrap.min.css
// ...
],
// ...
],component-id = string An ID of the component.
section-name = string A Section name (of the component-id.)
file-id = string A File ID (defined inside the files of section-name of component-id.)
Include a different component's file url.
// Example
'bootstrap' => [
// ...
'css' => [
// ...
['bootstrap-min.css', '@id'=>'core-minified']
// ...
],
// ...
],
'font-awesome' => [
// ...
'css' => [
// ...
'icons/font-awesome-min.css',
// Include `bootstrap` component's base url
'@componentFile(bootstrap/css/core-minified)',
// output: /cdn/bootstrap/css/bootstrap.min.css
// ...
],
// ...
],Copyright (c) 2016 Junaid Atari and it's contributes.