Daniel
Daniel

Reputation: 539

Customize Twitter Bootstrap with less in symfony2

I've to solve a basic issue. The website has multiple sections and each of them uses an own colortheme. So want to change the .less varibles depending on which page the user visits.

For example (pseudo code):

If request.get('_route') == 'section1'
    @primary-color: red;

I'm asking google for a while, but I can not get it work. I can use the less compiler under symfony, but I cannot override variables and I do not know how to inject logic/values form outside into less. Maybe someone can help me out with a simple example where to put what?

Upvotes: 0

Views: 77

Answers (1)

David Jacquel
David Jacquel

Reputation: 52819

From inside your main template, you can assign the route name as a class on your body element :

<body class="{{ app.request.attributes.get('_route') }}">

In your custom style less file you can declare specific variables and rules :

.homepage{
  @primary-color: red;
  color: @primary-color;

  .childclass{
    ....
  }
}

Upvotes: 1

Related Questions