Output Assets

The headAssets() method will echo the formatted contents of stylesheets, jshead, jsexternal, as well as anything in $config->styles.

If using a minification module and minify is set to true, the engine will output the results of the module's combine/minify function, otherwise it will output all of the assets individually.

Note that the engine will not combine/minify anything in $config->styles, because the location of those assets is unpredictable, and may be located within the modules folder. Also, it is recommended that you avoid using $config->styles and $config->scripts for managing assets because you won't be able to take advantage of the reordering and other methods of the module. Some modules, like Soundmanager2 will auto-populate the $config->styles and $config->scripts arrays, so that module will function properly in the front end when using the theme engine, but those assets will not combine/minify. If you wish to combine/minify when using a module that has dependencies, you should specify the assets using the engine, and then ignore the $config arrays. The engine will include an option to choose to not output $config arrays, though it will output those by default.

// In head:

$theme->headAssets();

// In Foot

$theme->footAssets();

The Theme Engine will not minify by default, you will have to choose the setting in the module's config.

Prior to the module config setting, you would do this:

Assuming you have this in your _init.php:

if(!$user->hasRole('superuser')) {
    $theme->minifyCSS = true;
    $theme->minifyJS  = true;
}

//or just this if you wanted to test minification 
// when you are logged in...

$theme->minifyCSS = true;
$theme->minifyJS  = true;

This will output something like this for logged in users:

<link rel="stylesheet" href="/site/templates/iris/css/fonts.css?v=1335464574">
<link rel="stylesheet" href="/site/templates/iris/css/style-boxed.css?v=1346714222">
<link rel="stylesheet" href="/site/templates/iris/css/isotope.css?v=1335464574">
<link rel="stylesheet" href="/site/templates/iris/css/fancybox.css?v=1335464576">
<link rel="stylesheet" href="/site/templates/jplayer/jplayer.css?v=1335464600">
<link rel="stylesheet" href="/site/templates/iris/css/mqueries-boxed.css?v=1335663866">
<link rel="stylesheet" href="/site/templates/iris/css/flexslider.css?v=1335472766">
<script type="text/javascript" src="/site/templates/iris/js/jquery-1.7.1.min.js?v=1335464612"></script>
<script type="text/javascript" src="/site/templates/iris/js/jquery.modernizr.min.js?v=1335464610"></script>

for non-logged in or non-super admin users, if you have ProCache installed:

<link href="/site/assets/pwpc/pwpc-f904fba39728efc469d9de7b4ce76db4718b17fc.css" rel="stylesheet">
<script src='/site/assets/pwpc/pwpc-d8cc7d1069699f1f73b1d20a7381138a5d19cab0.js'></script>

Last updated