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

Step 4: Add a Custom Class to Each Taxonomy Term: Name Field

The answer is in Tokens, which Views calls Replacement Patterns. Tokens are little bits of text, usually surrounded by brackets (e.g., [link]), which you can use to replace other text. So, for example, I can create a custom class for each instance of the Taxonomy Term Name field, by inserting a token for the name into the CSS class for that field.

Creating the token was a little bit tricky. The first step is find the actual token; to do this, I had to pretend I was rewriting the field.

If you click on the name of any field in your Views settings, you’ll see a few drop-down areas that let you set up different parameters for the field. With the Image field, you already saw the Style Settings variable. If you check out the options under Rewrite Results (see Figure 13-11), you’ll notice an option: “Rewrite the output of this field.” This is highly useful if you want to create very specific code from Views. The rewrite options are how we’ll create our custom class.

If we choose the option to rewrite the field’s output, there’s a host of things we can do with it

Figure 13-11. If we choose the option to rewrite the field’s output, there’s a host of things we can do with it

In order to find the token I needed to create my new Views class, I had to check the option to rewrite the field output. Underneath the checkbox, you’ll see a new dropdown called “Replacement Patterns” (see Figure 13-12). That will give you a list of the replacement ...

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