Skip to main content

Drupal 7

pseudo field in view

Drupal 7 - Exposing pseudo field in view from custom table

Introduction:

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.

Creating pager

Creating pager in Drupal (without db_select() and PagerDefault)

Pager: no new to the dictionary of Web, plays an important role in reducing long scrolling and improvises the visual look of the site. One of the pages in my site lists statistics based details. It wasn't that appealing to go ahead with this page which had almost 100 plus items to display. At this point I had a sudden idea to split the statistics with the help of pager.

Drupal 7 SOLR

Drupal 7 filtering SOLR results

Search plays a crucial role in content driven websites. Drupal and the Open source enterprise search platform Solr form a effective combination. Drupal 7 has apachesolr module which  integrates Drupal with the Apache Solr search platform. I am going to detail on how to alter the solr query to get better and precise results.

knackforge blog knowledge base

Setting browser tab/ window title from Drupal menu

One of the Drupal sites we did recently had a requirement to set browser tab (or window) title from Drupal menu. Usually it will be h1 title of the web page in Drupal that will be shown as tab title. Even the modules like page_title module doesn't seem to have any configuration for our case. But there is always some APIs and hooks to rescue the developer. For our case, the following eight line snippet did the trick,

lightbox2 with nodes

Display nodes with Lightbox2

Lightbox a powerful module in Drupal arena., proved its mastery once again! I was involved in trying to find a way to display nodes in popup, the apparent module that struck my way was Colorbox-Node. Things looked as if it would be a cake-walk but went beyond what I thought. The Colorbox-Node holds the ability to display nodes in overlay effect, but it needs huge template and jQuery level customization.

knackforge blog knowledge base

Configure Apache Solr with Tomcat

At many times Drupal Architects prefer to go with Apache Solr instead of Drupal core search. I am no outlander to this scenario, but this time it was a new requirement. By default the Apache Solr relies on Jetty server to index and retrive items during the search. My need was to use Tomcat server in the place of Jetty. The first glance proved it was an easy task, but latter the tough fight started.

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().

Subscribe to Drupal 7