Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include css from resources folder in symfony 2

I hvae the css located in

app/Resources/FOSUserbundle/css

How can i include that in my twig template

The reason i am putting css there is that my all overridden FOSUser templates in in that folder. So i want to keep css , js images all in there so that if i need to use in other website i just copy that folder

like image 700
Mirage Avatar asked Jan 12 '12 14:01

Mirage


1 Answers

I'm not quite sure how you would include that in your TWIG templates, but ...

1) I put the resources I use in several bundles / projects in the web/ directory. Then you can reference then like this:

{% stylesheets 'css/styles.css' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}

2) If you need to override the FOSUserbundle anyway, you can put the resources inside the inheriting bundle, referencing them like this:

{% javascripts '@YourBundle/Resources/public/js/scripts.js' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
like image 141
Michael Sauter Avatar answered Nov 02 '22 23:11

Michael Sauter