Different css resources in layouts

I would like to split my website to two area "Admin area" and "User ares", and the two areas should use different css files.My approach is as following:

{# path : /app/views/layouts/user.volt #}

<?php
    $this->assets
            ->addCss('css/bootstrap.css')
            ->addCss('css/user.css');
?>

<div id="container">
    {{ content() }}
</div>
{# path : /app/views/layouts/admin.volt #}

<?php
    $this->assets
            ->addCss('css/bootstrap.css')
            ->addCss('css/admin.css');
?>

<div id="container">
    {{ content() }}
</div>
{# path : /app/views/index.volt #}

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Foo</title>
    {{ this.assets.outputCss() }}
</head>
<body>
    {{ content() }}
</body>
</html>

Is this a good approach? Or there is better one?



7.2k

You are completely free to use assets collections in any action of any controllers in any combinations of assets :)



771

Thanks for your response. But I am curious about the side effect when I use assets collections in my layouts view rather than action of a controller.