Think Of Blocks As Containers For Content

Printer-friendly versionPDF version

Blocks are one of my favorite Drupal features. Here's what I like about Drupal blocks.

  1. You can use blocks as a very simple way to customize the look of your site.
  2. Blocks can contain lists of posts, widgets or even custom php code snippets.
  3. Certain themes, like Artists C01, and modules, like panels, allow great control over the display of content.
  4. You have a great amount of control over who sees a block and where they are placed.

There are several ways that you can put more blocks into action on your site.

  • Many modules will add special blocks to your site. For example, the image module adds a random image block which I'm using on this site. When you install a new module check to see if it has added any blocks that you can use.
  • You can create your own blocks by adding text, HTML (or even PHP) code. Just got to admin/build/block/add on your Drupal site. You can do just about anything you want here. You can display images or add widgets like Flash video players and image slideshows.
  • More advanced site builders can utilize the views module to create dynamic blocks from content on their site.

I like to think of blocks in Drupal as flexible containers for content. Blocks don't have to be located in the sidebar. Blocks don't have to be visible by all users (see Show block for specific roles:). Blocks can be located on any page you want (see Show block on specific pages:).

Here's an important tip for those of you who want to add your own content to a block. Double check the input format for your  block. Embedded javascript widgets and images require that you choose the Full HTML input format in order to display the content properly.

So if you haven't worked with blocks too much yet I recommend that you spend some time becoming familiar with this very excellent feature of the Drupal platform.

Bookmark and Share Bookmark or Share Post

Comments

HinanuiGalina's picture

Hyperlink in a block

Hi Robb,
How can I make the title of a block a hyperlink ? I've investigated drupal.org and the administration section of my Getting started site but couldn't find anything I understood...Thank you in advance

learnbythedrop's picture

Linking Block Title

How you would do it would probably depend on how the block was created. For example, you could create a block by entering text and html at /admin/build/block/add. If you leave the "Block title" field blank then you could set up the first line of the "Block body" as the linked title and then add the rest of the content below.

If the block data is generated by a view or another module you might be able to do it by altering the block theme. How to Make a Block Title Link on Drupal.org seems to provide some good information on how to do that.

HinanuiGalina's picture

Got it

I'd better take baby steps and learn html first! Sorry for this naive question...Thanks for your time

learnbythedrop's picture

Rich Text Editors

If you add a rich text editor to your site (WYSIWYG API module is very helpful) you won't need to know much html.

Anonymous's picture

Add a block or region in the top right corner

Hello Robb,

I have been searching the web for a solution to a question that I have.

I intend to have my login panel placed in the top right corner of the page. To achieve that, I created a custom block and now I don't know how to place where I want it to be.

I am using pixture reloaded theme on my site.

Thanks in advance for your kind answer.

learnbythedrop's picture

Locating Blocks

When you're on the blocks administration page the theme should displays the different locations where you can place a block for that theme. I believe that it's pretty unusual that you would locate a block in the top corner of the page. I assume that you're talking about the top corner above the header.

You may want to use the corner module (http://drupal.org/project/corner), which allows you to place an image link in the top corner, to create a link to the login page.

Post new comment

Important
All comments on this site are moderated to prevent spam. Although we also use the Mollom module we have found that some gets through and that also affects people who have subscribed to email notifications. If you would like your comment to appear immediately please login with Google Friend Connect which supports your Google, Twitter or Yahoo account.
Google Friend Connect (leave a quick comment)
Loading
The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
Mollom CAPTCHA (play audio CAPTCHA)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.