Skip to content Get in touch

Contact form

Developing with NetBeans (Part V): Drupal

Code templates

Drupal community provides a set of code templates for NetBeans. These templates will allow you to develop Drupal modules much faster.

Download it from its project page and configure it as explained there.

The idea is very simple: whenever you need to implement a hook, you just type the name of the hook and the entire hook template will show up automatically. There are templates already made for many hooks, such as form_alter, form_id_alter, init, user_insert, block_info or cron.

Of course you can add your own hook templates as well, or edit the exiting ones to accommodate your needs.

For example, the following entire piece of code was created automatically after I typed the word ‘block’:

Drupal Developer Plugin

NetBeans community provides the Drupal Developer plugin which consists of 2 parts:

API Search

Search for any hook or theme, with autocompletion. It will open the hook related page in the site.

API Browser

Similar to the previous, but useful if you are not sure about the name of the hook or theme. It basically lists all enabled hooks organised in folders. It also includes the description of the hook, so you don’t need to leave NetBeans for reading it.

It is a window, so open it clicking on Window, Drupal, Drupal API:

Double click on it for creating the hook template automatically in your code. Just complete!

More about this topic

Other thoughts

More thoughts