Posted By

psynaptic on 06/19/09


Tagged

textmate drupal hookblock


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

annalog
ReeceMarsland


Drupal hook_block 6.x


 / Published in: PHP
 

  1. <?php
  2.  
  3. function hook_block($op = 'list', $delta = 0, $edit = array()) {
  4. switch ($op) {
  5.  
  6. case 'list':
  7. $blocks[0]['info'] = t('Block 1');
  8. $blocks[1]['info'] = t('Block 2');
  9. return $blocks;
  10.  
  11. case 'configure':
  12. if ($delta == 0 && user_access('administer module')) {
  13. $form['module_block_1'] = array();
  14. }
  15. if ($delta == 1 && user_access('administer module')) {
  16. $form['module_block_2'] = array();
  17. }
  18. return $form;
  19.  
  20. case 'save':
  21. if ($delta == 0) {
  22. variable_set('module_block_setting_1', $edit['module_block_1']);
  23. }
  24. if ($delta == 1) {
  25. variable_set('module_block_setting_2', $edit['module_block_2']);
  26. }
  27. break;
  28.  
  29. case 'view':
  30. if ($delta == 0) {
  31. $block['subject'] = t('Block 1 title');
  32. $block['content'] = t('Block 1 content');
  33. }
  34. if ($delta == 1) {
  35. $block['subject'] = t('Block 2 title');
  36. $block['content'] = t('Block 2 content');
  37. }
  38.  
  39. return $block;
  40. }
  41. }

Report this snippet  

You need to login to post a comment.