1

I do a lot of theming but I don't have much in the way of php skills. So when I use or create a cool piece of javascript, I put it into my theme layer. The problem is, 90% of the time it doesn't belong there, and I really can't share what I've done with others.

So, how can I create a module, basically as a wrapper, for js code? I need to know more about that basic custom module structure and also the php used to insert js and css. Bonus would be basic info about creating blocks, content types and views with the module rather than creating them on the site UI.

3

If you've done work with themes and template.php, writing a module will be a snap. Review Creating Drupal 7.x modules for the basics, but at a minimum you need a yourmodulename.info and a yourmodulename.module file to get going. Declaring the block specifically will start you off on being able to define your blocks. As for including css and js, use the drupal_add_css and drupal_add_js functions respectively.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.