I've added a stylesheet in a template inside a module I've built, using a combination of drupal_get_path and drupal_add_css. I've confirmed the path is right (the stylesheet is properly added when I use the exact same code in the actual module itself), and I've done this in other template files in the past, but this time the stylesheet isn't being loaded. I've tried clearing the cache, and even clearing the theme directory, but it's not working for me.

document structure:
user_announcements (folder)
- css (folder)
- user_announcements.css
- templates (folder)
- user_announcement.tpl.php

There are other files of course, but these are the relative ones. Inside user_announcement.tpl.php, I am using this line of code:

<?php drupal_add_css(drupal_get_path('module', 'user_announcements') . '/css/user_announcement.css'); ?>

The template file is definitely working (the code is being rendered properly using the template file) but no matter what I do, the stylesheet isn't being loaded. Any ideas anyone?

Comments

Jaypan’s picture

My document structure formatting got lost in the save. It should have looked like this:

user_announcements (folder)
  - css (folder)
      - user_announcements.css
  - templates (folder)
      - user_announcement.tpl.php

I will soon be leaving the Drupal forums permanently. To understand why, please see this thread.