Faery
Faery

Reputation: 4650

How to write the path to my css file in Symfony2

Sorry for this question, but I don't remeber how exactly the paths were written, so please help me to specify my path.

My base template where I want to specify the path to the css file is here (if it is a good idea to add the path to the css file in the base template at all):

Project/app/Resources/views/base.html.twig

And the css file is here:

Project\src\Acme\MyBundle\Resources\public\css\style.css

I also run assets:install so the css file is here too:

Project\web\bundles\acmemybundle\css\style.css

So my question is to where to give the path in base.html.twig (to the web folder or to the folder in my bundle) and how exactly to write it:

<link href="{{ asset('path') }}" rel="stylesheet" type="text/css" />

Upvotes: 1

Views: 1322

Answers (1)

user1236048
user1236048

Reputation: 5602

Normal link:

<link href="{{ asset('bundles/acmemybundle/css/style.css') }}" rel="stylesheet" type="text/css" />

If you want to apply cssrewrite filter:

{% stylesheets filter='cssrewrite'
  'bundles/acmemybundle/css/style.css'      
 %}
  <link rel="stylesheet" href="{{ asset_url }}" media="screen" />      
{% endstylesheets %}

If you want to apply compress filter

{% stylesheets filter='?yui_css'
  '@AcmeMyBundle/Resources/public/css/style.css'      
 %}
  <link rel="stylesheet" href="{{ asset_url }}" media="screen" />      
{% endstylesheets %}

Upvotes: 4

Related Questions