Blogs on

Drupal 7

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

Continue reading

Changing the number of blog posts to show in blog page

Every small finding is worth sharing. This blog post is no except for this fact. Drupal ships with a module for blogging since a long time. This mighty module offers a potential multi-user blogging feature to Drupal site. This is an essential module for most of the contents publishing site. Blog content has been architectured to leverage node. A new blog can be created by any user with permission "Blog entry: Create new content" as of Drupal 7.

Continue reading

Add Placeholders to Captcha input field

HTML 5 has been encompassed with many novel attributes, one of which is the Placeholders. The Placeholder attribute displays text in the input field till it is focused and then hides the text on click. These Placeholders plays an momentous role in offering a visual information about the field. A general place where I prefer to add Placeholders is template.php in your theme. 

Continue reading

Altering Rules action using hook_rules_action_info_alter()

Rules no novel to Drupal area, are always considered as the unsophisticated way to accomplish action. A paradigm of rule's dominance can be witnessed in sending a mail after a user account creation, Blocking a Specific user from accessing the site, Providing access to products in Drupal Commerce, etc. Rules can be created either programmatically or by using piece of code.

Continue reading

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.

Hooks to be used:

Continue reading

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.

Continue reading

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,

Continue reading

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.

Continue reading

About Knackforge