Last active
August 29, 2015 14:13
-
-
Save timodwhit/613a7c43c80eaaa3f48f to your computer and use it in GitHub Desktop.
Sublime Snippet for Custom Block in Drupal 7
This file contains hidden or 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
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is based off of: http://kahthong.com/2013/06/create-your-own-custom-drupal-block-programmatically with slight adjustments