Views Rewrites
Making Fields Do What They Don’t Do
If you've spent any time with Drupal, you've heard of — and likely installed — the Views module. If you haven't, then you're very likely working harder than you need to! Views is Drupal's query builder, enabling you to create lists of just about anything, as well as providing basic formatting and the ability to do basic formatting of your items. Although Views will be merged into Drupal 8, if you've never used it before, take a look.
Since most Drupal designers have used Views, they generally know its power: Yes, it will relate data to other data, sort, filter, and so on. But one very helpful feature neophytes may not have discovered is its ability to rewrite fields. In essence, a field can be added to the display, but in the settings for that field you have the option to “rewrite” that field; it will keep the settings of that field, but will masquerade as something else: it can be changed to plain text, to a link, or even to another field entirely. Here, we’ll walk you through some examples, and then talk about other options this feature offers.
Why would I do that?
There are plenty of reasons: your field may not contain all the data you want; it might have too much data; it might not have all the settings you want or behave in the way you need. However, some other field just might accomplish those chores. Read on.
Lynette Miles
Lynette Miles is the co-author of Drupal's Building Blocks, and has worked in the tech industry for her entire professional career. She became involved with Drupal in 2006, and participates in the documentation team as well as coordinating the Views bug squad.