Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When using drupal_get_css, leave off the beginning slash.
Example:
$path = drupal_get_path('module', 'my_module');
drupal_add_css(drupal_get_path('module', 'my_module')."/my_module-style.css");
This took me a bit to realize and got some help from Heine.
Comments
Comment #1
Heine CreditAttribution: Heine commentedIt should be relative to the drupal root, modules/devel/devel.css.
See also drupal_get_css,
if (file_exists($file)) {
and below,Comment #2
jhodgdonThis is a duplicate:
#618280: drupal_add_css() documentation bug