Same name and namespace in other branches
- 4.7.x developer/examples/block_example.module \block_example_contents()
- 5.x developer/examples/block_example.module \block_example_contents()
A block content function.
File
- developer/
examples/ block_example.module, line 64 - This is an example outlining how a module can be used to define a block to be displayed on the right or left side of each page.
Code
function block_example_contents($which_block) {
if ($which_block == 1) {
// Modules would typically perform some database queries to fetch the content
// for their blocks. Here, we just return a string.
return t('Some example content.');
}
if ($which_block == 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;
}
}