Introduction to Drupal 7                               Session 5.2                           Blocks managementDrupalist: K...
Agenda•    Drupal blocks•    Regions•    Managing blocks the easy and quick way•    Managing blocks in contexts•    Case s...
Drupal blocks• A block is a generic term that is applied to any  self-contained piece of content, menu, or  code.• They ca...
Regions• In order to place a block into a given place,  you need to have a region for this• Regions depend on the theme yo...
Default Bartik theme regionsDrupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   5
Managing blocks• Managing blocks with the handles• Using the drop-down optionsDrupalist: Kalin Chernev      Course by Init...
Managing blocks• From the contextual links in the front-end• Then edit the block from the back screenDrupalist: Kalin Cher...
Blocks tips and tricks• Removing block title       – The <none> short codeDrupalist: Kalin Chernev        Course by Init L...
Blocks with configurations options• Some blocks have configurations       – Menu blocks have list links and edit menu     ...
Blocks visibility settings by Pages• You can set whether the  block will appear       – only a given set of         pages ...
Blocks visibility by content types• You can set  instructions for a  block to appear only  when a given  content type is s...
Blocks visibility by roles• You can also set a  given block to be  visible for a specific  user roles only• You can use th...
Blocks visibility by users• Very rarely used  option• It’s better to define  the necessary blocks  with your client  preli...
Blocks management with Context• Another way to manage blocks is with the Context module• Advantages       – Contexts can b...
Enabling Context and Admin modules• Enable the Context core module• Enable also the Context UI module to be able  to confi...
Let’s create some contexts• We want the slideshow to be displayed on the home  page only• Go to admin/structure/context an...
Homepage slideshow context      You can now switch off the block from the blocks      management screenDrupalist: Kalin Ch...
Create a feature for your work• Taking only the newly created context for the  home page with the block should be enoughDr...
Time for questionsDrupalist: Kalin Chernev       Course by Init Lab (http://initlab.org)   19
ContactsKalin Chernev       – E: kalata@shtrak.eu       – T: twitter.com/kalinchernev       – U: http://shtrak.eu/kalataDr...
Upcoming SlideShare
Loading in …5
×

Introduction to Drupal 7 - Blocks management and contexts

5,608 views

Published on

Blocks management in Drupal 7. Visibility settings by pages, content type and roles. Going one level up on blocks management using the Context module.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,608
On SlideShare
0
From Embeds
0
Number of Embeds
263
Actions
Shares
0
Downloads
68
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Introduction to Drupal 7 - Blocks management and contexts

  1. 1. Introduction to Drupal 7 Session 5.2 Blocks managementDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 1
  2. 2. Agenda• Drupal blocks• Regions• Managing blocks the easy and quick way• Managing blocks in contexts• Case study – arranging your website blocksDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 2
  3. 3. Drupal blocks• A block is a generic term that is applied to any self-contained piece of content, menu, or code.• They can be: – System blocks: login block, search block, etc – Modules blocks: latest news block, slideshow – Custom blocks – Programmatically build blocks (with coding)Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 3
  4. 4. Regions• In order to place a block into a given place, you need to have a region for this• Regions depend on the theme you’re using• To check your theme regions, go to admin/structure/block and click on the Demonstrate block regionsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 4
  5. 5. Default Bartik theme regionsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 5
  6. 6. Managing blocks• Managing blocks with the handles• Using the drop-down optionsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 6
  7. 7. Managing blocks• From the contextual links in the front-end• Then edit the block from the back screenDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 7
  8. 8. Blocks tips and tricks• Removing block title – The <none> short codeDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 8
  9. 9. Blocks with configurations options• Some blocks have configurations – Menu blocks have list links and edit menu – Views block have views configurationsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 9
  10. 10. Blocks visibility settings by Pages• You can set whether the block will appear – only a given set of pages – or on any pages, except a given set of pages• You can use <front> short code to target the home page• We want the slideshow to be visible only on the home page for exampleDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 10
  11. 11. Blocks visibility by content types• You can set instructions for a block to appear only when a given content type is seen• In our case we don’t use this option, but you can use it when for example you want to show a relevant articles block only on news articlesDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 11
  12. 12. Blocks visibility by roles• You can also set a given block to be visible for a specific user roles only• You can use this option for example to display a content management menu only for the Office Assistant user role• Or you can use this settings to show content for Premium (Paying) users only, etcDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 12
  13. 13. Blocks visibility by users• Very rarely used option• It’s better to define the necessary blocks with your client preliminary and set the blocks for them• Blocks management in the end is a pretty complex logic for a regular userDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 13
  14. 14. Blocks management with Context• Another way to manage blocks is with the Context module• Advantages – Contexts can be compiled in features – Contexts can be re-arranged with drag and drop from administrators with the Admin module – Cleaner way to manage blocks – Clean categorization possible – More options than the default blocks management capabilities• A bit not so advantages – You have to know what’re doing with a bit of though beforehand, or you’re re-make contexts all the time – If you have more than 1 block in 1 region, separated in different contexts, you don’t have control on the order of display of the blocksDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 14
  15. 15. Enabling Context and Admin modules• Enable the Context core module• Enable also the Context UI module to be able to configure contexts with user interface• Enable the Admin module to be able to edit contexts with and inspector and drag and drop• Go to admin/config/user-interface/admin to place the Admin options on the bottom right (because we have the Administration toolbar enabled on the top)Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 15
  16. 16. Let’s create some contexts• We want the slideshow to be displayed on the home page only• Go to admin/structure/context and click the “Add” link to create a new context• Place slideshow_homepage for a name of the context, always make it machine readable• Place a tag Home page for better categorization• Select a Path condition and add <front> in the field so that the context is valid for the home page only• From the Reactions, place the slideshow views block in the Features region, as we have it nowDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 16
  17. 17. Homepage slideshow context You can now switch off the block from the blocks management screenDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 17
  18. 18. Create a feature for your work• Taking only the newly created context for the home page with the block should be enoughDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 18
  19. 19. Time for questionsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 19
  20. 20. ContactsKalin Chernev – E: kalata@shtrak.eu – T: twitter.com/kalinchernev – U: http://shtrak.eu/kalataDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 20

×