Skip to main content


view exposed filters

Drupal Views exposed filter as Links

In Drupal views, we have the option of exposing the filters to users. By default, the exposed filters are displayed as Select boxes. Recently in a multilingual project, there was a requirement to display Courses based on Language. And the Languages had to be shown as links. In order to achieve this functionality, the Views exposed filter had to be customized.

To start with the customization, we need to alter "views_exposed_form" using hook_form_alter

pseudo field in view

Drupal 7 - Exposing pseudo field in view from custom table


At KnackForge we often see requirement to expose custom fields to views for better integration with Drupal flow. In this article we are going to see steps to expose a custom field from a custom table. Infact its a virtual field. 

Use case:

Assume you have two custom fields total_marks and marks_obtained in a custom table. Now you need to calculate the percentage of mark scored. You don't need a field in table for this. You can create a virtual field bound to marks_obtained field.

views alter

Altering views table output

Views module provides an easy way to render data from the Drupal database. It is often needed to use table output format to meet the design requirements. One such similar occasion needed customizing the table output.

The scenario was, we had a list of discounts with validity date as its one of the attributes. We wanted to show expired discounts in a different color to distinguish it from active discounts. What helped us was hook_preprocess_views_view_table().

knackforge blog knowledge base

Playing with Views API

Views, one of the most powerful module in the Drupal ecosystem. It has a great ability to create custom pages specific to project requirements from within Drupal admin interface without having to write any code. But at times it may become tedious even for the Views module to accomplish a few usecases. At such a point, things can be achieved programmatically by leveraging the API. This post aims at providing a practical piece of codes pertaining to Views for different scenario.


Creating mailchimp campaign from view output

MailChimp is a Web service offering platform for e-mail marketing. It is easy to start, use and scale. In short we can design, send, and track HTML email campaigns/newsletters with simple tools. There are  lot of things that makes us feel that MailChimp is the right choice for our needs. The list goes on with API to sync from inhouse sites/ applications, intuitive reports, integration with existing services like Facebook, Twitter and Google analytics, ability to create custom forms, etc. Of course we like MailChimp's humor as well. 



How to alter views field output programmatically

Amending the view output is no longer a tedious task. Especially by taking the advantage of settings available in Views 3.x like exclude from display, style settings, rewrite results and their sub-settings. The change can be anything simple from adding a <span> wrapper for CSS styling to complex token replacement (thanks to token module for making the Views module more awesome).



Drupal 7 pager not visible/ showing

Of late in two of my Drupal sites I found that pagers were not shown. This happened independent of active theme and modules generating the page (views,  panels, or core blog module). Essentially I reproduced this in the Recent logs messages page and default Blogs listing page (?q=blog). Below is the snapshot of how it looked to me.

Subscribe to Views