Drupal 7

3 Easy Ways to Create View Modes in Drupal 7

View modes allow site builders to display the same piece of content in various ways. Drupal ships with a bunch of them out of the box like Teaser, “Full content”, RSS and much more. There is even one for the search result page called “Search result”. However, the two most prominent are Teaser and “Full content”.

The “Full content” view mode is the one used to display content on its “node/123” page. It’s the one you’ll customise the most. Teaser, on the other hand, is used to display a summarised or trimmed down version of an article.

You can create as many view modes as necessary. But like many things in Drupal, they can be created in a few ways. They can be implemented using code and with a module or two.

In this tutorial, you’ll learn how to create view modes in three ways: using hook_entity_info_alter(), using Display Suite and Entity view modes.

Control Context Using Context Entity Field in Drupal 7

When you need to dynamically display a block within a region, nothing can really beat the Context module. It allows you to define a set of conditions, that when met, executes a set of reactions. For example, you could create a context rule which adds a block to the sidebar second region (reaction) when a user is viewing an Article content type (condition).

A lot of what Context does can also be achieved using Panels. But if you’re new to Drupal, and never used Panels than Context will be easier to use.

If you’re new to Context then I would highly recommend you watch the two introductory videos below:

Recently I’ve discovered a powerful module called Context entity field. It allows you to define a condition that checks the value of a field on an entity.

Using Environment Indicator in Drupal 7

Every Drupal site builder will at some point experience the dread of accidentally making configuration changes on production thinking it’s their local site. This sort of thing can easily happen when you have 20 tabs opened and forget which site you’re currently browsing.

Luckily there’s a module you can use to indicate which environment (local, staging, production, etc.) you’re currently viewing and it’s called Environment Indicator.

The module helps to separate each environment by displaying a coloured indicator. The indicator itself is fully configurable. You can change its colour, position and text.

In this tutorial, you’ll learn how to create an indicator in two ways: through the module’s UI and with some code in settings.php.

How to Send HTML Emails in Drupal 7 using Rules

There are a few benefits in sending emails as HTML. For one thing, they can be styled and images can be displayed. Also, it’s easier to track open rates and clicks if the email is HTML. However, there are some downsides to using HTML. One thing I’ve read about is that HTML emails are more likely to be flagged as spam. Especially if your whole email is just a single image.

In this tutorial, you’ll learn how to use Mime Mail to configure Drupal to send HTML emails. We’ll also look at how to send them using Rules.

How to Use Bootswatch Themes in Drupal 7

The standard look and feel of Bootstrap is unmistakable and often you can spot a website using it a mile away. The dead giveaways are the buttons and navigation, but it doesn’t have to be this way.

If you want to change the look and feel of your Bootstrap site then take a look at Bootswatch. It offers 12 great looking themes, and best of all they are free and open source.

In this tutorial, we’ll learn how to use a Bootswatch theme in two ways. The first method will show you how to use the BootstrapCDN and in the second we compile the LESS files ourselves.

How to Export Views Using Bulk Export and Ctools

So you created a module that you want to put on drupal.org. But just before you release it, you realise it could do with a few default views.

You may think you can use Features for this, but Views allows you to ship default views by creating a module.views_default.inc and implementing hook_views_default_views.

Now, Ctools can be used to generate the required export code that needs to be placed in hook_views_default_views. We’ll use a sub-module in Ctools called “Bulk Export” to generate the code.

It’s important to understand that there is a difference between “Bulk Export” and Features. The difference is that you can only export CTools’ configuration objects using “Bulk Export”. Whereas, Features offers full API for integrating any module with it.

In this tutorial, you’ll learn how to export default views using “Bulk Export”.

Display Custom View Modes on Individual Nodes Using Display Suite

When it comes to managing the look and feel of a content page, nothing can beat Display Suite. It’s become an essential module for when you need to change the layout and fields on a node or any entity page.

Today I want to talk about a piece of functionality that you may not be aware of in Display Suite. It’s the ability to switch the view mode will be used for an individual node.

Let me explain, when you go to a node page (node/1) the “Full content” view mode is displayed. But, you can only have a single version of this view mode for each content type.

Display Suite can be setup to allow authors to select a specific view mode on an individual node.

Display Bootstrap Components using Views Bootstrap

Bootstrap is a mobile first front-end framework that allows a developer to build websites quickly. The framework comes with a lot of reusable CSS styles, components and jQuery plugins.

One thing I like about Bootstrap is its CSS styles and components. You get access to all sorts of useful things like Tables, Thumbnails and more.

Now, implementing these components in Drupal can be tough. You can either change Drupal’s markup or use Mixins.

But there is a module that can help you display components (and some plugins) within a View; and it’s called Views Bootstrap.

The module allows you to use components and CSS styles directly from the Views edit page without overriding templates or creating mixins.

In this tutorial, I’ll show you how to create a “Recent articles” block using Views and the Media object component.

New Videos: How to Post Tweets Using Custom Code and More

Today we released the last three videos for the series on integrating Twitter and Drupal.

We finished off the “Posting Tweets” chapter with the final video: How to Post Tweets Using Custom Code.

There’s also a new chapter called “Extras”. Here, you’ll learn how to allow users to log in and register into Drupal using their Twitter account. You’ll also learn how to add inline username and hashtag links using Twitter filters.

How to Send Follow-Up Emails Using Rules Scheduler in Drupal 7

On a community website, it’s a good idea to send some type of follow-up email a week or month after a user registers. This email can be used to ask for feedback or promote useful features.

This type of functionality can be built in a few ways. You could use a 3rd party email service like MailChimp or AWeber to send the follow-up as an auto-responder.