Created
July 20, 2012 12:04
-
-
Save benhosmer/3150369 to your computer and use it in GitHub Desktop.
Drupal 6.x Block Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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