BackendPro User Guide Version 0.6.1


Conditional Assets

Using the Asset Library it is possible to have conditional CSS assets. A conditional CSS asset defines certain conditions for when to load it, if the conditions match then its loaded. Example conditions are as follows:

Other than creating the new file you don't need to do anything else. When ever you include the original asset the loader will check to see if it needs to include any conditional assets.

How to define Conditional Assets

Once you have defined your normal assets in modules/site/config/bep_assets.php all you have to do is create a new file in the same folder as the original asset using the following naming convention:

<asset_file_name>[<operation>_<browser>_<version>].css

Examples

  1. Say we had an asset file called reset.css and we wanted to have another asset file which would only load when someone visited your website using Internet Explorer. You would create the following new file.

    reset[ie].css
  2. So the above is all well and good if the CSS is needed for all browsers of that type, but what if we want to load it for only a certain version? Say again we had a reset.css file but this we wanted some CSS to load when a user visited the site using Firefox 2.0.

    reset[ff_2.0].css
  3. The last option is to specify an operation to perform on the browser version. So say we want to load a conditional asset if its greater than or equal to Internet Explorer 5.0

    reset[gte_ie_5.0].css

Options

In the examples above you will see I have used certain values to specify when to load the asset, these fall into 3 categories: