Home
A blog about web development and Drupal.

api

June 12, 2014

Writing Field Handlers for Views

While working on a recent project, we found ourselves in a situation where we needed to customize a Views field in a way that was not possible using Views' configuration or theming. In such cases, writing a custom Views handler might be the best or only option. Let's assume the following scenario: we need to build a list of contents that has two columns. The first column shows the content's title, and the second shows the content's status. If the content is published, the second column shows the date the content was created, but if it is not published, the field in that column only shows…

March 1, 2011

Using Views to Avoid node_load()

One of the most versatile Drupal modules, Views, comes with an impressive user interface that allows you to capitalize on all its functionality – or does it? Although this interface is the primary means of using Views, the module has plenty to offer on the code level too. Recently I was working on a task that involved selecting nodes of a certain type from a huge list of node IDs. When it comes to data manipulation on a complex web site, a web developer needs to take due precaution. An inefficient SQL query can bring the site to its knees by creating a performance bottleneck. So I looked into…