You are here

Creating Custom Code Templates

There is a very simple template system involved for creating new code. Let’s look at the template for hook_block (Drupal 6) as an example. If you navigate to the code/Drupal 6/hooks/core/ folder and open the block.tpl file, you will see the following:

{syntaxhighlighter brush:php}

* Implements hook_block();
function ${file_name}_block($op = 'list', $delta = 0, $edit = array()) {


That is the code that’s inserted into your document with a couple of replacement variables:

${file_name} – Changes to the base name of the file you have open, so if you are working on test.module, the function declaration will become:

{syntaxhighlighter brush:php}
function test_block($op = 'list', $delta = 0, $edit = array()) {

The only other variable currently available is ${set_cursor}. This variable simple sets the position your cursor will be at after inserting the code into your document.

Once you have made your changes, simply close and reopen that document in Netbeans and the changes will take effect.