This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Best way to include css in a module?

I'd like to ask people's opinions on the best way to include css into a module. An example might be event.module which includes is own css file using:

$output .= theme('stylesheet_import', drupal_get_path('module', 'event') .'/event.css','screen');

This is a good way to include the css, but if a user wants to change parts of it for their own theme they either have to include the changes in their style.css file or change the module version of the css file. The latter is not ideal as later on in an upgrade you would need to merge the new (module defined) css file and your css changes, and it is not theme specific.

One method that I have used is to include the module css file as above, but also look in the theme dir for a css file and if it is there also include it (after the module version). So the code looks like:

global $theme;
if ($theme === NULL) {
    $theme = init_theme();
}
$output .= theme('stylesheet_import', drupal_get_path('module', 'gallery') .' drupal_g2.css','screen') ."\n";
$themecss = path_to_theme() .'/drupal_g2.css';
if (file_exists($themecss)) 
          $output .= theme('stylesheet_import', $themecss,'screen') . "\n";
}

There is a kludge here in that sometimes the $theme variable is not initialised yet and so path_to_theme() returns nothing, so I have to call init_theme().

New Module: Append_Here - for shortcutting directly from 'view page' to 'add child'

Note: This is only relevant to 'heirachical' site structures based on menu.module.

It's sort of an extension to menu-On-The-Fly.

Thinking like a user, I found the whole 'create content' route a bit cumbersome, especially when the 'navigation menu' was getting large and I had to use it only after creating a node.

I'd appreciate any feedback on if there are better ways to do things in this code - over-riding the form 'action' in the nodeapi feels like a bit of a hack ... but it works well!

.dan.

Google API Search module

Hi,
I just finished developing a Google API module. It could be seen in action here: http://news.healthelp.org . I am waiting to post the module to the Drupal CVS, if aproved, but in the mean time you could find it here: http://www.solutionsdepot.com.

Please send me any sugestions you may have related this module.

Thanks

ecommerce cart module problem

following error appear, when i "continue to payment details"

Fatal error: Call to undefined function: store_transaction_validate_overview() in /home/www/web162/html/modules/ecommerce/cart/cart.module on line 272

and this when i try to "create transaction"

Fatal error: Call to undefined function: store_transaction_overview_form() in /home/www/web162/html/modules/ecommerce/store/store.module on line 729

Please Help, Im a newB
Thnx

OpenID module gotchas

I'm working on a module to support drupal logins using OpenID. For those of you not familiar, OpenID is a decentralized identity system. In OpenID, a users identity is keyed by a url that represents them. A "Consumer" is the site that the user wants to log in to, i.e. drupal, and the "Server" is the site that knows about the user.

Book tracking module...

I know this one is likely a pipe dream, but you can't make dreams a reality without trying. :)

I would love a module that provides features similar to what BookCrossing.com does. An ability to write reviews, track where you leave a book (or comic, in my case) and who picks it up/where it is picked up, etc...

If something like this already exists, please let me know. I'd create it myself but I have *NO* programming ability (yet, anyway).

Peace, respect and thanks...

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions