Is it possible to use rules to temporarily add css in the head of page, say after a node submit?

I have tried using drupal_add_css but I am assuming it is not working because the page elements are already built by the time I get ready to add my message.

Comments

mitchell’s picture

Title: Possible to add temporary inline css? » Action: drupal_add_css
Version: 7.x-2.0 » 7.x-2.x-dev
Component: Miscellaneous » Rules Core
Category: support » feature
plato1123’s picture

Issue summary: View changes

Anyone know if rules can add css?

tr’s picture

Status: Active » Closed (won't fix)

I have tried using drupal_add_css but I am assuming it is not working because the page elements are already built by the time I get ready to add my message.

Yes, that's going to be true for rules triggered by any event except "Drupal is initializing".

I don't think it makes sense to use Rules to add CSS or JavaScript. There are better ways and better places in Drupal to control the page appearance. I don't know your exact use case, but think about adding classes to the tags on a page so that they may be styled differently based on EXISTING CSS, rather than adding new CSS. This can be done in the theme layer, using templates, theme functions overrides, etc.