Drupal 7
I found a very interesting article by Stephen Tweeddale from the team at Computer Minds referring to the correct way to extract a value from a Drupal array/object combination... If you use the trusty PHP function print_r(); on $node, (a la print_r($node); ), you'll see a great list of information,…
Recently I had to redirect users to the home page, and although I can do this with the 'Rules' module, I also wanted to add something to the $_SESSION for some custom code...
After a little digging I found this: http://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_login/7…
Similar to another post aimed at using a different page.tpl.php for a certain content type, sometimes I've needed to call in the node via an iframe or similar, so I really need a different html.tpl.php for a certain content type...
I've laid the content out in a similar way to the other post…
For every settings page you'll need to use the Form API to allow the user to add/edit the configuration values. This is a simple example of the form and the submit function.
/**
* Form builder: Create and display the configuration settings form.
*/
function MY_MODULE_NAME_form($form, &$…
Adding a module configuration or settings page to the main Drupal menu is an important task and I like to add a page for each module I build...
Even if it's more of a 'help' page to explain what the module does or how to use it.
Adding one page is fairly simple....
/**
* Impliment hook_menu…
hook_permission() is a handy way to allow certain roles to access certain pages, i.e. the 'Administrator' to change settings and say 'Comms Team' to view the results. As per a lot of Drupal building the return value must be a nested array, and that can be tricky to remember... So here is an example…
Sometimes it’s handy to use a different page.tpl.php for a certain content type. Maybe the page has a different layout, needs additional regions not used on other pages, etc…
For starters, lets use some example names/variables, lets say:
The theme I’m using is called ‘myTheme’
The ‘content…