Skip to content

Instantly share code, notes, and snippets.

@benhosmer
Created July 20, 2012 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhosmer/3150369 to your computer and use it in GitHub Desktop.
Save benhosmer/3150369 to your computer and use it in GitHub Desktop.
Drupal 6.x Block Example
<?php
function all_projects_block($op = 'list', $delta = 'all_projects_link') { // Make the delta a string, it is easier!
$block = array();
switch ($op) {
case 'list':// This lists the block in the admin>blocks page
$block['all_projects_link'] = array( //You have to reference the delta for $op 'list' otherwise it won't work
'info' => t('2.1-All Projects Block'),
'weight' => 0,
'status' => TRUE,
'visibility' => '1',
'pages' => '<front>',
'region' => 'header',// The region should exist in your theme!
);
return $block;
case 'view'://This displays the block on the page.
$block = array( //You can't reference the delta here during $op 'view'
'subject' => t('All Projects'),
'content' => '<em>Bawk!</em>',
);
}
return $block;
}
?>
// There is a variable set in the block table that is the same as the $delta in the database that you should delete when testing block code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment