Appearance
Adding assets
Each Box can define its own CSS and JS assets. The assets will be included on demand, as soon as a Box is rendered.
INFO
If the same Box is rendered multiple times, the assets are still only included once. Keep this in mind while writing your code!
Registering Assets
To register assets, place them under a assets
property in your Box config.
yaml
assets:
js:
- name: /plugins/acme/demo/assets/js/some.js
attributes:
async: "async"
css:
- name: /plugins/acme/demo/assets/css/some.css
bundle: true
You can define the following keys for each asset:
Attribute | Type | Description |
---|---|---|
name | String, required | The path to the asset (as you would pass it to a ->addJs() method) |
attributes | Dictionary | Additional attributes for the HTML tag (as you would pass it to a ->addJs() method) |
bundle | Boolean | If the asset should be combined with other assets or be included on its own. |
Note
The assets are included using October's asset pipeline.
So for this to work you need to place the {% styles %}
and {% scripts %}
tags in your layout.
Including the October AJAX Framework
Use the following config to include October's AJAX Framework:
yaml
handle: box-with-framework
assets:
js:
- name: /modules/system/assets/js/framework-extras.js
bundle: true
# or include the framework without extras:
# - name: /modules/system/assets/js/framework.js
# bundle: true
css:
- name: /modules/system/assets/css/framework-extras.css
bundle: true