Posted under » Drupal on 2 July 2011
Before we go on to concepts such as hooks or callbacks, let create a bare minimum module. For both drupal versions, it is the same thing. You need 2 basic files.
The info may look like this
name = Nafi description = A collection of nafi nonsen package = NAFI core = 7.x
The module may look like this. Mostly containing functions and classes
function nafi_heh($heh) { echo "hello world"; }
If you try to upload this to drupal 6, it will fail because you info it as ver. 7. A simple changing to "6.x" will clear the error.
Think of it like an include. You can use the function in any post, just make sure you enable the "php filter" module.
An advantage is that you use drupal for all your SQL requirements without resorting to hacks.
The CSS works by just putting it here.
To add CSS
You must add this to your module.
drupal_add_css(drupal_get_path('module', 'nafi') .'/nafi.css', 'module');