Defining asset locations for styles
Okay, stick with us here, as this takes some explaining, but it's worth it for the pay-off...
With XenForo 2.2, we're introducing the concept of
Asset locations for styles, which can be used to define locations, usually directories, in which assets for your style are stored.
Assets can be anything from a font, a JavaScript file, an image or even a directory containing multiple files.
This is an example of how you might set up one of your styles:
Here we have defined an asset key called
logos
and pointed that at the
styles/my_style
directory.
Now this is defined, you are free to use the
logos
asset location in various places including in templates with the
asset('logos')
template function and style properties using the
%ASSET:logos%
placeholder.
These style properties now
directly reference the three logo files in the
styles/my_style
directory that we defined as an asset location. If we ever change that asset location, it will update these three style properties automatically to point at the correct location.
Style asset locations are extremely powerful for child styles, too. You may want to make a derivative of this style which may involve changing some properties, and changing some of the logos to reflect your changes.
By default, child styles inherit style asset locations from their parents:
Much like style properties, you can customize an existing
asset location in a style or you can add entirely new locations. Just type into an empty field to add a new one, or click the pencil icon to edit an existing one:
Because the style properties are also inherited from the parent and they are making use of the
logos
asset, no changes need to be made to the style properties themselves. The logos will now be served from the newly defined asset path.