Skip to content

Instantly share code, notes, and snippets.

@timodwhit
Last active August 29, 2015 14:13
Show Gist options
  • Save timodwhit/613a7c43c80eaaa3f48f to your computer and use it in GitHub Desktop.
Save timodwhit/613a7c43c80eaaa3f48f to your computer and use it in GitHub Desktop.
Sublime Snippet for Custom Block in Drupal 7
<snippet>
<content><![CDATA[
/**
* Implements hook_block_info().
*/
function ${1:YOUR_MODULE}_block_info() {
\$blocks = array();
\$blocks['${2:YOUR_BLOCK_ABC}'] = array(
'info' => t('${3:YOUR BLOCK NAME}'),
);
return \$blocks;
}
/**
* Implements hook_block_view().
*/
function ${1:YOUR_MODULE}_block_view(\$delta = '') {
\$block = array();
switch (\$delta) {
case '${2:YOUR_BLOCK_ABC}':
\$block['subject'] = '';
\$block['content'] = _${1:YOUR_MODULE}_${2:YOUR_BLOCK_ABC}_content();
break;
}
return \$block;
}
/**
* Custom Content Function
*/
function _${1:YOUR_MODULE}_${2:YOUR_BLOCK_ABC}_content() {
\$output = t('Hello world');
return \$output;
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>drupal_block</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
@timodwhit
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment