Get URL Parameters


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.

Memcached Config For Drupal On Ubuntu

Memcached is a free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load

Memcached is used in Drupal mostly for caching Database queries in memory to improve authenticated user experience and reduce load on database. Primarily cache tables are swapped to have a memcached backend.

Keyboard Key bindings in Ubuntu


My laptop keyboard faced a particular problem with both Ctrl keys not working. It was a hardware issue and only keyboard replacement would resolve. I searched for alternatives where I could replace any key not being used to Ctrl key.

xmodmap is a utility for modifying keymaps and pointer button mappings in Xorg.

To do the same, I replaced the Menu Key in keyboard(keycode = 135) which acts like a right click and mapped it as right control key. To do so, one would need to create the file ~/.Xmodmap and update with the following data.

MySQL handly commands


To prevent duplicate entry issue - replace INSERT into with REPLACE INTO .
DEF: REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted.

REPLACE into table (id, name, age) values(1, "A", 19)

Run Optimize of All tables of a database:

mysqlcheck -o db_to_optimize  -udb_user -p

All databases

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.