$block = module_invoke('module_name', 'block_view', 'block_delta');<br/>
'module_name' = The machine name of the module (i.e. the module's folder name). This is true for core modules too, so for instance 'search', 'user' and 'comment' would all work here.
'block_delta' = The machine name of the block. You can determine what this is by visiting the block administration page and editing the block. The URL for editing a webform block, for instance, would be something like:
Drupal 7: admin/structure/block/manage/webform/*client-block-11*/configure
In this example, 'webform' is the module's name, 'client-block-11' is the block's delta.
Custom blocks will have module name of 'block' and a number for a delta, which you can also find by editing the block.
More information: http://drupal.org/node/26502
If you want blocks to be shown only on pages with specific tags, this is an example implementation.
This will insert beans with the tag-field enabled into a page with similar tags.
It is assumed that both bean type and node type has field_tags.
The bean type is called tag_sensitive_block, and the code simply calls for all beans of this type and collects those that share a tag with the current node. Then it inserts $max_beans beans into the first and second sidebar, switching between them after each insert.Read more
One of your most difficult jobs as a site administrator is soliciting inbound links to boost your traffic and your search engine position. Deep links, in context, are the most valuable.
Using the 'Path of Least Resistance' philosophy, provide users with link text at the bottom of every page using the following code snippet (D7) in a block.Read more
This documentation is written for the 7.x-2.x version of Display Suite.
Display Suite allows you to put certain fields inside a region that will be rendered as a block. This can then be managed via the Drupal core block administration.
Note: this works only for custom view modes of nodes. Preprocess fields will not be visible.
To add fields to a block:
- Enable the sub module Display Suite Extras at Administration > Modules (admin/modules)
- Go to Administration > Structure > Display Suite and click the secondary tab "Extras" (admin/structure/ds/extras)
- Select the vertical tab "Others"
- Check "Region to block"
- Click "Save configuration"
- Go to Administration > Structure > Display Suite (admin/structure/ds/layout) and choose "manage display” for the desired content type (e.g., "Article").
- Select a custom view mode (e.g., "Compact teaser")
- Ensure a layout is selected in the vertical tab "Layout for … in ..."
- Choose the vertical tab "Block regions"
- Enter a name for the region that will be rendered as a block
- Click "Save"
The region is now available in the manage display screen and you can assign fields to it.Read more
Author's note: the Context section of this page would benefit from screenshots. During the presentation, I was able to demo the options, but obviously that doesn't work as well with static docs. I'll add them myself in time, unless someone beats me to it. End Note
Blocks and Menus
Every time you create a menu, a corresponding block is created that displays that menu.
You can also create custom blocks at admin/structure/block/add.
Now that we have these blocks, we need to display them.
The two commonly used methods of controlling block display are the core block display functionality, or the contributed Context module. Both means achieve the same goal; the context module provides more flexibility.
Core Block display
The core block visibility settings can be accessed at admin/structure/block.
To display a block in a region, use the drop down menu for the block you want to show:
In addition to setting the region for a block, you can also set additional features by using the "configure" link visible in the above screenshot.Read more
Designers can create multiple tpl.php files for blocks based on the specific block, the module that created the block, or the region that the block appears in.
In Drupal 7 template files are searched in the following order:
If the block delta key uses a hyphen, (-), replace this with an underscore (_).
Drupal 5 & 6
In Drupal 5 and 6, template files are searched in the following order:
For example, the user login block has a delta of '0'. If you put it in the left sidebar, when it's rendered, PHPTemplate will search for the following templates in descending order:
Finding module and delta
You can find the block's module and delta by looking at the html source of a page: each block's main DIV has the following classes and IDs: