Thursday, January 20, 2011

Drupal in NetBeans

Where to get it: http://drupalmodules.com/module/netbeans-templates

No this isn't a Drupal module, but where would something like this live otherwise? :) It's a collection of templates used within NetBeans and makes coding must faster. There are quite a few templates and it can take some time to figure them out, but the author did a good job using some naming conventions. For example, "h_menu" will insert a full template for hook_menu resulting in:

function mymodule_menu(){

  $items = array();

  $items['path'] = array(
      'title' => 'title',
      'description' => 'description',
      'page callback' => 'callback',
      'page arguments' => array('callback_arg'),
      'access arguments' => array('access_arg'),
      'file' => 'includes/mymodule_type.inc',
  ); 
 
  return $items;


}

After the template is inserted, mymodule is automatically selected and ready to be edited to the actual name of your module.

Installation instructions (as of NB 6.9):
  1. Rename nb_templates.zip.txt to nb_templates.zip
  2. In NetBeans, goto Tools > Options > Editor > Code Templates  and press the import button at the bottom.
  3. Browse and find nb_templates.zip, and select it.
  4. Select Editor > Code Templates
  5. Press OK

A must have for NetBeans users.

No comments:

Post a Comment