Next Tutorial

Drupal 7 Tutorial Part 15: Drupal 7 Advanced Taxonomy Concepts

Drupal 7 Tutorial Part 4: Understanding Drupal 7 Blocks Concept

Submitted by anilsagar on Thu, 05/05/2011 - 21:19

Hi Everyone,

 

In last tutorial we learnt what is a node in Drupal. Now, we will see what is a block in drupal and how to add a block, display block in different pages of drupal website.

 

What is a block in drupal ? :

 

  • Block is a visible area that displays data in different regions of a drupal website.

The above answer arises one question. 

 

What is a region in drupal ? :

 

  • Regions are nothing but drupal page is divided into various sections or parts known as regions where data can be displayed. To examine the regions in Drupal 7 follow below steps.
  • Login to your drupal website as administrator. You will see screen something like below.

 

  • Now click on Structure link on top black menu bar you will see a popup with links. Now click on blocks section. You will see page something like below.

  • Now click on Demonstrate block regions like which is just above Add block link. Now you can see various drupal regions of your site. Just like below page.

  • You can see various regions such as Header, Featured, Sidebar First, Sidebar second etc.In these above regions we can place blocks. So, lets try to create some blocks and enable them in above regions.

How to create a block in drupal 7 and enable them ?

 

      We can create Drupal Blocks using two ways.

  • Using Drupal Administrator User Interface.
  • Using PHP code and Drupal API.

           As a beginner let's see how to create a block using drupal adminstrator interface. In my future posts when i am dealing with module development i will explain how to create block using php code and drupal api.

 

  • Login as a adminstrator into your drupal 7 site. Now click on Structure menu link on top admin navigation bar. Now you can see a overlay with various links. Click on Blocks link. To add a new block, click on Add Block link in blocks section. You will see page like below when you click on add block link.

 

  • Give block description as "Contact Us Block". This will apppear in blocks manage section. Basically, block description is administrative name to identify block.
  • Fill Block title text field as "Contact Us".
  • Fill Block body as

No 201, 6th Main,
MG ROAD, Bangalore,
India, 560094
Mobile: +91- 80XX788XX8

  • Now go to region settings and select "Sidebar second" for bartik theme and leave the field seven (adminstration theme). More about these setting i will discuss in my next tutorial.
  • Now click on Save Block button. Immediately after submit you will be redirected to block manage page and you will see a status message "The block has been created.".
  • Now go to your home page. You can see contact us block that you created on home page right hand side in "sidebar second region." Just like below.

 

So finally we learnt how to create a block and enable them in different regions. Stay tuned with me to learn more about block settings and configurations in my next post.

 

Cheers,

Anil Sagar

11 comments

Thanks

Submitted by Paul (not verified) on Wed, 01/04/2012 - 21:05.

Thanks Anil! I've been reading your series of Drupal 7 posts - they're great!

paul.

thank you

Submitted by ronald (not verified) on Tue, 11/01/2011 - 17:00.

thank you for this very helpful yet simple tutorial. I am getting started on drupal and this was definitely helpful.

href inside of a block

Submitted by mike (not verified) on Sat, 10/22/2011 - 00:58.

how do you make a link within a block visible to visitor?

Hi Mike

Submitted by anilsagar on Sat, 10/22/2011 - 09:49.

Select the input format as Full Html Under the body text area and place the a href tag with the link. That should work.

Cheers,
Anil Sagar

Thanks

Submitted by Sanal (not verified) on Sat, 09/24/2011 - 14:27.

Thanks . Tutorials are very helpful for me

Very detailed tutorial on how

Submitted by Jason Hummer (not verified) on Wed, 09/21/2011 - 15:20.

Very detailed tutorial on how to create a website using drupal. I'm a newbie in term of drupal type of content management system, trying to find some online tutorial from basic to expert level. This is a good start type of tutorial.

How enable this new block for several users?

Submitted by Jomoliveira (not verified) on Fri, 09/16/2011 - 14:55.

Hi,
I can do that, but when I log out my user or user admin and I becomes anonymous, I cannot see this new block, particularly whether this block is a Menu.
Can you hepl, telling me what I need do in addition?
Thanks in advance.

Thank you!

Submitted by Chad (not verified) on Tue, 08/16/2011 - 03:44.

These are brilliant - really easy to follow and feels like I'm getting somewhere fast rather than getting too bogged down! Thanks!!!

Thanks!

Submitted by Cisneros (not verified) on Thu, 06/16/2011 - 23:11.

Thanks!

I'm also following, thanx very much man

Submitted by rookie (not verified) on Sat, 06/11/2011 - 21:47.

I'm also following, thanx very much man

Thanks alot. I am following

Submitted by Anonymous (not verified) on Thu, 06/09/2011 - 00:42.

Thanks alot. I am following your tutorials and are very helpful

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.
©2010 AnilSagar. All rights reserved. Drupal theme by Kiwi Themes.