Drupal 7

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 :

Fixing Issue: Fatal error: "Maximum execution time of 240 seconds exceeded"

Search for drupal_set_time_limit in Drupal directory and modify the line as below. Ensure that it is restored later once the required operation is over:
For example: Modify the following line in locale.inc file in includes/locale.inc.


and set to 1800.

Organic Groups Views Exposed Filter Selection

It becomes very frustrating when one had to try various options but not be able to create drop down list of groups for selection via an exposed filter option in a view.

There is a very simple solution to it. In the Group Audience field settings, select "Render Views filters as select list" option under ADDITIONAL BEHAVIORS. This selection would make the Group Audience field selected as an exposed filter display drop down options of all the groups available.

Drupal File Operation

This post will illustrate various handy file operations available in Drupal

Get Absolute Path of a file from URI : drupal_realpath()
A URI in drupal looks like: private://donor_registration/somefile.csv for a private file
Absolute Path: /srv/www/example.com/public_html/sites/default/private/files/donor_registration/somefile.csv

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: