function block_example_contents in Examples for Developers 6
Same name and namespace in other branches
- 7 block_example/block_example.module \block_example_contents()
A block content function.
Related topics
1 call to block_example_contents()
- block_example_block in block_example/
block_example.module - Implementation of hook_block().
File
- block_example/
block_example.module, line 96 - This is an example outlining how a module can define blocks to be displayed on each page.
Code
function block_example_contents($which_block) {
switch ($which_block) {
case 1:
// Modules would typically perform some database queries to fetch the
// content for their blocks. Here, we'll just use the variable set in the
// block configuration or, if none has set, a default value.
return variable_get('block_example_string', t('A default value.'));
case 2:
// It is possible that your block will not have any content, since it is
// probably dynamically constructed. In this case, Drupal will not display
// the block at all.
return;
}
}