PHP

Actions in Views Bulk Operations

Views Bulk Operations come handy when doing bulk operations over a selected list. This is great because it combines the power of views to filter the selection and specific actions to do on each selected entity. For Ex: Updating some field in the record, deleting selected entity and so on.

Views also provide an easier way to define your own set of custom functions to perform on each selected row of entities.

First, we need to define an action :

Get URL Parameters

Technologies: 

There are multiple methods for getting current URL parameters. The following seem to work fine.

filter_input — Gets a specific external variable by name and optionally filters it . Works on PHP 5 >= 5.2.0.

The following code gets the districts from the url provided in the parameter field_district_ref_nid. The filter input converts the result into an array.

Drupal l() and url() methods

Both l and url methods are handy to create urls for various entities. However, the variety of options available makes the usage exciting and complex.

l(): Formats an internal or external URL link as an HTML anchor tag.
Syntax: l($text, $path, array $options = array())

Creating an absolute URL using l(). The example below creates a node link.

Creating exportable field definitions in Drupal 7

There are times when we would want to create similar data structures across multiple drupal sites for common functionalities. Although this can be done using features but when the effort involves one time exercise and involves just few fields to be exported, using custom code for creating export definitions for importing in the other site can be a simpler alternative.

If you want export a field definition, you can use the handy field_info_field and field_info_instance functions. Taking our example above, here's how you would call these two functions:

Batch API

Drupals internal batch API can be really helpful for handling large cumbersome processes on your web server. Rather than submitting a form and waiting for one of these processes to finish before reaching the next page, the batch API can be utilized to break the process down across multiple page loads. This not only cuts down on the server load, but will prevent the page from timing out. Progress bars will be displayed to the user while the process runs which will keep them informed of where they are at in the process.

Modify Integer field to Decimal

Technologies: 

The purpose is to modify the integer field which captures temperature in decimal.

A good way is to execute a hook_update_N() API in custom module which allows incremental updates when installing, or visiting update.php
WARNING: Does not work. Its better to recreate field after copying data to another temp field.
[ http://drupal.stackexchange.com/questions/103157/modifying-integer-field... ]

Allow HTML markup in quicktabs

Technologies: 

Quicktabs by default strips html tags in Quicktab title by default. To add additional markup of text changes, hook_quicktabs_alter() is not sufficient the quicktabs tabset needs to be overriden to allow html markup in titles.

hook_quicktabs_alter() to modify title. In the example modification for the first tab is done