Display suite part 2: View modes and fields

Update: I have written an updated version of this series over at http://webwash.net. The updated version covers Display Suite 7.x-2.x.

This post is part of a Display suite series, Display suite part 1: Layouts and Styles and Display suite part 2: View modes and fields.

In part 2 of this Display suite series, I'll show you how to create custom view modes and how to expose blocks as a field. Also don't forget to check out the Display Suite for Drupal 7 playlist on youtube.

Custom views modes

In Drupal 7 entity view modes have become a lot more powerful. With Display suite you are able to create custom view modes for any node or comment, without writing any code.

NOTE: Check out this great blog post on how to create custom view modes in Drupal 7 with code.

To create a custom view mode, click on the View modes link from the Display suite administration page.

76_14_1.png

Click on Add a view mode, fill out the form then click on Save.

76_15.png

If we go back to the Manage display, you should see the view mode in the Custom display settings tab.

76_16_1.png

Exposing blocks as fields and custom fields

One of Display suites strength is the ability to create custom fields and exposing blocks as fields, let me explain.

Click on Fields link from the Display suite administration page.

76_17_1.png

Let’s say you want to add some hard coded call to action text into a content type display. You can do this by creating a field, then assigning it to a region like any other field.

Click on the Add a field link and fill out the form. Make sure you select the right Text format, for this example select Filtered HTML.

76_18.png

The other ability is to expose blocks as fields and then assign them to a region.

Click on the Add a block field link. Give the field a name then select which block you want to use from the Block select box.

Fill out the rest of the form then click on Save.

76_19.png

Go back to the Manage display page and assign the custom fields to a region.

76_20.png

As you can see Display suite is a very powerful module. It saves site builders from overriding a lot of templates.

If you have any problems or questions please leave a comment.

Category: 
Tags: 

Ivan is the founder of Web Wash and spends most of his time consulting and writing about Drupal. He's been working with Drupal for 6 years and has successfully completed several large Drupal projects in Australia.

Connect: Twitter drupal.org LinkedIn App.net