Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable CSS stylesheet for a specific action in Symfony

Tags:

css

symfony1

Is there any way of disabling a stylesheet in view.yml for a specific action in Symfony?

For example I've got this in my view.yml:

default:
  stylesheets:    [default.css]

I want to be able to do something like:

displaySuccess:
  stylesheet: [!default.css]

to disable default.css in displaySuccess only

Is this possible or do I have to explicitly say which modules/actions should have default.css?

like image 382
dazpinto Avatar asked Dec 01 '10 15:12

dazpinto


3 Answers

You can remove or add stylesheets to a modules view.yml by doing the following:

displaySuccess:
  stylesheet: [-default]

would remove default.css from the display action. Simply putting

displaySuccess:
  stylesheet: [-*]

would remove all stylesheets.

like image 115
cvaldemar Avatar answered Oct 19 '22 23:10

cvaldemar


to remove for example, unecessary /sfDoctrinePlugin/css/default.css, now you can overwrite the backend styles with your own!

maybe put it into yout layout.php:

<?php sfContext::getInstance()->getResponse()->removeStylesheet('/sfDoctrinePlugin/css/global.css'); ?>

<?php sfContext::getInstance()->getResponse()->removeStylesheet('/sfDoctrinePlugin/css/default.css'); ?>
like image 2
imonori Avatar answered Oct 20 '22 00:10

imonori


I'm not 100% certain, but I believe the compiled view.yml file is processed before execution of the action. If that's true, you can do:

public function executeDisplay()
{
  $this->response->removeStylesheet('default.css');
}

I find view.yml to be a little inflexible. You may find it easier to have a global "head" template that gets included in your layout(s). Then you can check sfConfig values to see if you should include individual files, making it easier to turn them on and off.

like image 1
Jeremy Kauffman Avatar answered Oct 20 '22 00:10

Jeremy Kauffman