Skip to main content

Installing Drush using Composer

Submitted by system on
With the advent of Drupal 8 and composer integration, there is a better way of installing Drush. Install Composer: curl -sS https://getcomposer.org/installer | php
Enable Composer access for All Users: mv composer.phar /usr/local/bin/composer
ln -s /usr/local/bin/composer /usr/bin/composer

Install Drush: git clone https://github.com/drush-ops/drush.git /usr/local/src/drush
cd /usr/local/src/drush

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

Submitted by system on
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. <?php drupal_set_time_limit(240); ?> and set to 1800. -- Source https://www.drupal.org/node/2085515#comment-7845525

Displaying field values with formatting

Submitted by system on
Displaying data for any entity fields with formatting can be achieved with 2 simple drupal api. field_get_items: Returns the field items in the language they currently would be displayed. field_view_value: Returns a renderable array for a single field value. Example: <?php $status_field = field_get_items('node', $node, 'field_status'); print render(field_view_value('node', $node, 'field_status', $status_field[0])); ?> -- Source https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_get_items/7 https://api.drupal.org/api/drupal

Get URL Parameters

Submitted by system on
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. <?php $districts = filter_input(INPUT_GET, 'field_district_ref_nid', FILTER_DEFAULT, FILTER_FORCE_ARRAY | FILTER_FORCE_ARRAY); dpm($districts); ?> -- Source http://php.net/manual/en/function.filter-input.php

Configuring Disqus for Drupal

Submitted by system on
Disqus is a networked community platform used by hundreds of thousands of sites all over the web. With Disqus, your website gains a feature-rich comment system complete with social network integration, advanced administration and moderation options, and other extensive community functions. Configuring Disqus for Drupal is pretty straightforward. Install the disqus module, enable viewing Disqus comments permissions for anonymous users.

Drupal l() and url() methods

Submitted by amitsedai on
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. <?php l(t('New product'), 'node/123', array('absolute' => TRUE)); ?> Add the previous url or the current page url before going to the new page.

Memcached Config For Drupal On Ubuntu

Submitted by system on
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. We can find a lot of tutorials to install Memcached on debian system including memcache PHP extension.

Keyboard Key bindings in Ubuntu

Submitted by system on
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. !clear the control keys
clear control

MySQL handly commands

Submitted by amitsedai on
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 mysqlcheck -o --all-databases -udb_user -p

Organic Groups Views Exposed Filter Selection

Submitted by amitsedai on
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.