Create a simple block view
- Navigate to admin/structure/views.
- Click Add New View.
- In the View Name field enter a name for the view.
- Click Description and enter a description.
- In the Show field, select one of the following options:
- Comments Sort options can be specified.
- Files Sort options can be specified.
- Content Content type, tags and sorting options can be specified.
- Content Revisions Sort options can be specified.
- Taxonomy Terms Tag type and sorting options can be specified.
- Users Sort options can be specified.
- Enable the Create a Block option.
- In the Display Format section, choose one of the following options:
- Grid
- HTML List
- Table
- Unformatted List
- In the Items to Display field, select the number of items to display.
Add fields to a block
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 moreDisplay random block
This snipped can by added in any PHP-enabled block to display a randomly selected block. The list of the blocks you want to be enabled are defined in the $myblocks array.
<?php
$myblocks = array(
// add your blocks here
'block1' => array(
'module' => 'views', //example
'delta' => 'Dependances-block_1', //example
),
'block2' => array(
'module' => 'block', //example
'delta' => '4', //example
),
'block3' => array(
'module' => 'mymodule', //module
'delta' => 'name_of_block_generated', //delta
),
);
$randomkey = array_rand($myblocks,1);
$block = $myblocks[$randomkey];
$blockloaded = block_load($block['module'], $block['delta']);
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($blockloaded))));
print $output;
?>Assigning content to regions
If none are defined, the following values are assumed in Drupal 6.
regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
Drupal 7 adds Highlighted and Help as default regions. By default, the textual content of the Help region is the same as the $help variable was in page.tpl.php for Drupal 6. The "machine" readable names of the sidebars have also changed names.
regions[sidebar_first] = Left sidebar
regions[sidebar_second] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[highlighted] = Highlighted
regions[help] = HelpDrupal 7 bartik theme has following default regions -
regions[header] = Header
regions[help] = Help
regions[page_top] = Page top
regions[page_bottom] = Page bottom
regions[highlighted] = Highlighted
regions[featured] = Featured
regions[content] = Content
regions[sidebar_first] = Sidebar first
regions[sidebar_second] = Sidebar second
regions[triptych_first] = Triptych first
regions[triptych_middle] = Triptych middle
regions[triptych_last] = Triptych last
regions[footer_firstcolumn] = Footer first column
regions[footer_secondcolumn] = Footer second column
regions[footer_thirdcolumn] = Footer third column
Theming blocks individually, by region, or by module
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.
Template suggestions
Drupal 7
In Drupal 7 template files are searched in the following order:
- block--block--[block-id].tpl.php
- block--[module]--[delta].tpl.php
- block--[module].tpl.php
- block--[region].tpl.php
- block.tpl.php
If the block delta key uses a hyphen, (-), replace this with an underscore (_).
Drupal 7 Template (Theme Hook) Suggestions
Drupal 5 & 6
In Drupal 5 and 6, template files are searched in the following order:
- block-[module]-[delta].tpl.php
- block-[module].tpl.php
- block-[region].tpl.php
- block.tpl.php
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:
- block-user-0.tpl.php
- block-user.tpl.php
- block-left.tpl.php
- block.tpl.php
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:
Working with blocks (content in regions)

Blocks are the boxes of content (such as "User Login" or "Who's online") that can be displayed in regions (such as footer or sidebar) on your page.
Blocks are made available to your site most commonly by enabling modules. Once created, a Block can be modified to adjust its appearance, shape, size and position - or which Website pages it appears on. For example, enabling the core Poll module makes the "Most Recent Polls" block available for you to place in a region. Also note that some modules provide multiple blocks when enabled, others may not define new blocks.

If you click "Configure Block" (Drupal 7) you can go ahead and edit the contents of the block, deal with the visibility settings and even change the placement of where it is on your theme.
Blocks are placed in regions via the Block Admin page Administer > Site building > Blocks (Drupal 6), Dashboard > Structure > Blocks (Drupal 7).
Read more