Skip to content

Section

Junaid Atari edited this page Aug 23, 2016 · 5 revisions

How to define sections

array

A name of the section without @ char at beginning, should be unique. A valid name contains [a-z][a-z0-9]+.

// Syntax
'component-id' => [
    // ...
    'section1' => [
    	// files here
    	//... 
    ],
    'section2' => [
    	// files here
    	// ....
    ],
    // other sections
]

Optional Properties

@attributes

array Pairs of key=>value.

Define the section attributes.

Default is []

// Example
'font-awesome' => [
    // ...
    'section1' => [
		'@attributes' => [
            'foo' => 'bar',
        ],
        // ...
    ],
    // ...
]

Functional Attributes

noNameInPathUrls

boolean (Default value: false)

Removes section name from paths and urls.

// Example

'font-awesome' => [
    // ...
    'css' => [
    	// ...
    	'@attributes' => [
        	'noNameInPathUrls'=>false
        ]
    	// ...
    ],
    // ...
],
How to access attribute?
/** @var \yii2cdn\Section $section */
$section = \Yii::$app->cdn->get('font-awesome')->getSection('css');

// Get attribute value
echo $section->getAttr('attribute');
// output: value

// Update/Set attribute
echo $section->setAttr('attribute', 'value');
// output: value

// Get all the attributes
print_r ( $section->getAttributes() );

Offline sections

Those section will be skipped when the constant YII2CDN_OFFLINE value set to false. (see Force using offline files )

Please use the @offlineSections property of the Cdn to define the offline sections:

// Syntax
'component-id' => [
	'@offlineSections' => [
    	'section1',
    ],
    // ...
    'section1' => [
		// ...
    ],
    // another section
    /*'section2' => [
		// ...
    ],*/
]

Note: the red links below are pages yet to be created. Feel free to add them!

Overview documents

  • README: distributed with yii2cdn, contains a quick overview of yii2cdn's functionality, an example, and the license.
  • REFERENCE: Containing incomplete api class reference.

Quick Start

Configuration

Tutorials

Clone this wiki locally