| Versions | |
|---|---|
| 4.7 – 7 | block_example_contents($which_block) |
A module-defined block content function.
examples/
<?php
function block_example_contents($which_block) {
switch ($which_block) {
case 'example_configurable_text':
// 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.
// Block content can be returned in two formats: renderable arrays
// (as here) are preferred though a simple string will work as well.
return array('#markup' => variable_get('block_example_string', t('A default value. This block was created at %time', array('%time' => date('c')))));
case 'example_empty':
// It is possible that a block not have any content, since it is
// probably dynamically constructed. In this case, Drupal will not display
// the block at all. This block will not be displayed.
return;
}
}
?>