views:

87

answers:

1

How can I affect the delta parameter value? Where it can be set?

I'm beginner with Drupal but know my way around PHP and other CMS apps e.g. Joomla. I've working on my first drupal module and need to create a module with multiple blocks. I know how to switch based on the $op parameter but the $delta value seems always to be the default value set in the function declaration.

How can I select which block to process and display? Can $delta be set so that when using modules subnavigation is uses delta to switch to another block view?

Thanks in advance.

+3  A: 

hook_block() is used for defining a and displaying blocks. You define the delta when you are producing the data for $op='list' this is passed back to the hook when it it is called for $op='view'.

the $delta argument will therefore be whatever you define. If you define the keys in your list array as red, green and blue that is what will be passed if the block is displayed.

Maby looking at the example will help you.

Jeremy French
+1 - the name 'delta' is an unfortunate leftover from earlier versions where the array defined on `$op = 'list'` was numerically indexed. Since you can use meaningful string indexes by now, 'name' or 'block_name' would be a better name for the parameter.
Henrik Opel
If I echo the value of $delta on the beginning of the 'view' it seems to always contain each different delta value available and not just a single one. I'm a bit lost on where should I define which delta value is to be used for producing content. I have 5 elements in the $block array defined in 'list'. I've got a switch ($op) and in the case 'view' I've got a switch ($delta) but each case is a match. If I set the delta value here it repeats the defined delta's content for all the 5 blocks.Sorry, I'm a new to Drupal and seem to be stuck with internal logic of Joomla :D
Jotudin

related questions