Simple block definition

Define and set content into a block. See hook_block_configure and hook_block_save if you want people be able to choose options.

  1. /*
  2. * Implements hook_block_info().
  3. */
  4. function mysnippet_block_info() { //define a new block
  5. $blocks['mysnippet']['info'] = t('Basic Block');
  6. return $blocks;
  7. }
  8.  
  9. /*
  10. * Implements hook_block_view().
  11. */
  12. function mysnippet_block_view($delta = '') { // define what to display
  13. switch ($delta) {
  14. case 'mysnippet':
  15. $block['subject'] = t('My title');
  16. $block['content'] = 'My custom block content'; // can off course be the return of a function...
  17. return $block;
  18. }
  19. }

Form field conditionnal display

In this snippet the text field mycustom is only displayed if the value of the select field myoptions is custom

Theme and render

display some content using drupal_render() and theme (this is the official way to use theme function)

Simple block definition

Define and set content into a block. See hook_block_configure and hook_block_save if you want people be able to choose options.

Form declaration (from menu to submit)

Output a simple form, with validation and submit handlers

Jquery file structure declaration

Declare custom jquery code (attached to a theme or module) so that $ selector is available