Skip to Content
Design and Prototyping for Drupal
book

Design and Prototyping for Drupal

by Dani Nordin
December 2011
Intermediate to advanced
170 pages
3h 50m
English
O'Reilly Media, Inc.
Content preview from Design and Prototyping for Drupal

Chapter 14. Managing Your Code: Some Modules that Can Help

Once you’ve broken down your layout, settled on your base theme, and wrangled your Views code, you can finally start theming your site. But where do you get started? How do you find the right selector to apply your CSS to? This is where it helps to add a couple of tricks. You can do a lot with themes and Views rewrite options in terms of cleaning up the code Drupal gives you so you can theme more efficiently. However, there are still issues with some of the ways that Drupal outputs code. The following modules can help.

Block Class

Block Class (drupal.org/project/block_class) is a little module that does something very important: it allows you to give any block its own class, independent of what Drupal wants to call it. This is useful, for example, when you want to create a block of featured content, or even a new class called “green” that you apply to random blocks in your theme.

For example, going back to our home page for Urban Homesteaders Unite, one of the things that we’re creating is an “about this site” block that describes what people can do here. If we look under the hood at what Drupal calls this block, we’ll see something akin to Figure 14-1.

See that long list of class names that’s highlighted? That’s our block.

Figure 14-1. See that long list of class names that’s highlighted? That’s our block.

Now, we’ve already got some styling set in this block just from our typography defaults. But ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Drupal 8 Module Development - Second Edition

Drupal 8 Module Development - Second Edition

Daniel Sipos
Using Drupal, 2nd Edition

Using Drupal, 2nd Edition

Angela Byron, Addison Berry, Bruno De Bondt

Publisher Resources

ISBN: 9781449311391Errata PagePurchase book