1

How do I require an asset group in the themes controller? Theme->requireAsset() only seems to handle single assets, not asset groups.

The asset groups is defined in the application/config/app.php

edit: I use 5.7 and this is an example of my code:

In config/app.php

'assets'        => array(
    'awesomejs'     => array(
        array(
            'javascript',
            'themes/mytheme/js/awesome.min.js',
            array('position' => 'H', 'minify' => true, 'combine' => true)
        )
    ),
    'greatjs'   => array(
        array(
            'javascript',
            'themes/mytheme/js/great.js',
            array('position' => 'H', 'minify' => true, 'combine' => true)
        )
    )
)

'asset_groups' => array(
    'myjavascripts' => array(
        array(
            array('javascript', 'awesomejs'),
            array('javascript', 'greatjs')
        )
    )
)

In page_theme.php

$this->requireAsset('javascript', 'myjavascripts');

this does not work since myjavascripts is an asset_group but all I seems to be able to do is require a specific asset in my theme, not an entire group.

1 Answer 1

0

Which version of the API are you wroking in 5.6.x or 5.7.x

If you are working in 5.7 then try

$this->requireAsset('redactor');

Where redactor is the name of the asset you want to require.

Also be sure to provide assets first before you require them as such:

    $this->providesAsset('javascript', 'bootstrap/*');
    $this->providesAsset('css', 'bootstrap/*');
    $this->providesAsset('css', 'blocks/form');
    $this->providesAsset('css', 'core/frontend/*');

This tells concrete where to find the asset files themselves, if it can't find them it cannot require them. Note you are only inputting the path, not the actual asset.

For your case you would use

$this->providesAsset('css', 'application/config');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.