how to disable drupal theme using drush command

Every drupal developer knows about drush and drush commands. If mistakenly you installed some broken drupal theme and you are not able to access site then you need change the drupal theme using drush command.

disable drupal theme using drush, Every drupal developer knows about drush and drush commands. If mistakenly you installed some broken drupal theme

disable drupal theme using drush

#drush vset theme_default seven

Using above command you can set the seven theme as default drupal theme. It will disable the your activated old theme.

Note: this command I given for drupal7

Drush 6 relase and added support for drupal 8 version

Two days ago Drush team  announced the release of Drush 6.

They moved there codebase to git now.

If you are drupal developer then you know the importance of drush. This is the bigest news for drupal developers.

Drush 6 relase and added support for drupal 8 version

Note: if you are using Drupal 8, you should stick with a frequently updated clone of master branch. Drush 6 supports Drupal 6+7 but not Drupal 8.

If you are using the linux then you can use following commands for updating the drush installation on your box.

Here I am assuming you already installed the drush on your linux box.

# pear install drush/drush-6.0.0RC4
# pear upgrade drush/drush

If you did not installed the drush then you can use the following link for drush installation.

Drupal interview questions for experienced Drupal Developer

I always take interview of many types of developers. These days drupal developers are really in demand but choosing right candidate who knows the drupal in and out is very difficult. So I created some very unique interview questions for experienced Drupal Developer and answers.
Experienced Drupal Developer needs Following strong knowledge:
Linux, Mysql, PHP, CSS and HTML, Apache, Software Design Methods, jQuery and AJAX, Drupal itself, Security, Search Engine Optimization

What is different between d6 and d7?
Ans: check this URL :

What are systems requirements for drupal installation ?
Ans:    Database: MySQL 5.0.15 or PostgreSQL 8.3
PHP Version 5.2 or higher
PHP Memory: 40M – 64M

what is entity  and entity api?
Ans: They provide a unified way to work with different data units in Drupal. Drupal 7 is all about entities. They are everywhere: nodes, users, taxonomy terms, vocabularies…

But how, as developers, can we create our own entities? When do we really need to do that? I think these questions are really very project-specific. We can probably use nodes for nearly everything. But when it comes to performance-sensitive projects, nodes should really only be used for content, and we should separate as much as possible from nodes. Why? Nodes are revisioned, they fire a lot of hooks, and they have functionality that we likely won’t need. Also if we know exactly what fields we should have in our entities, we can create our own custom entities to avoid all those joins of Field API tables.

what is use of user entity?
Ans: Check this URL:

What is hooks?
Ans:Allow modules to interact with the Drupal core.

Drupal’s module system is based on the concept of “hooks”. A hook is a PHP function that is named foo_bar(), where “foo” is the name of the module (whose filename is thus foo.module) and “bar” is the name of the hook. Each hook has a defined set of parameters and a specified result type.

How to do the for drupal debugging
Ans: – use devel module and Use xdebug  application

Which files are required for theme?
Ans: style.css, page.tpl.php, info file, template.php, node.tpl.php, block.tpl.php

Which files are required for module?
Ans:, modulename.module, optional modulename.install

which are common modules used in project?
Ans: WebformDevel, Drush, ViewsBackup & Migrate, Date, Address field, file field, link, media, Rules, SMTP, View Slideshow, Print,
Lightbox2, Varnish, memcache, Wysiwyg, ckeditor, Google Analytics, Metatag, XML Site Map, Redirect, Page Title, Chaos Tools,Token, Entity, Panels, Features, Coder

What is Drush – how drush is used?
Ans: Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

what is PDO?
Ans: PDO is an acronym for PHP Data Objects. PDO is a lean, consistent way to access databases. This means developers can write portable code much easier. PDO is not an abstraction layer like PearDB. PDO is a more like a data access layer which uses a unified API (Application Programming Interface).

How PDO used in drupal?
Ans: Drupal provides a database abstraction layer to provide developers with the ability to support multiple database servers easily. The intent of this layer is to preserve the syntax and power of SQL as much as possible, but also allow developers a way to leverage more complex functionality in a unified way. It also provides a structured interface for dynamically constructing queries when appropriate, and enforcing security checks and similar good practices.

The system is built atop PHP’s PDO (PHP Data Objects) database API and inherits much of its syntax and semantics.

How to use preprocess function?
Ans:The main role of the preprocessor is to set up variables to be placed within the template (.tpl.php) files. From Drupal 7 they apply to templates and functions, whereas in Drupal 6 preprocess functions only apply to theming hooks implemented as templates. Plain theme functions do not interact with preprocessors.

Where to use the theme hook?
Ans: template.php in theme folder

What is use of template.php file?
Ans: Overriding other theme functions. If you want to override a theme function not included in the basic list (block, box, comment, node, page), you need to tell PHPTemplate about it.

To do this, you need to create a template.php file in your theme’s directory. This file must start with a PHP opening tag

What is subtheme?
Ans:A Drupal subtheme (or sub-theme) is a theme that is based on a “base theme”. The base theme provides basic (and sometimes more than basic) functionality. The subtheme styles the site with a unique look, and adds any unique extra functionality.

Which modules used for data migration?
Ans: Feeds –
Import or aggregate data as nodes, users, taxonomy terms or simple database records.

How to handle localization in drupal?
Ans: Drupal 7 supports the localization.

How to use the multiple themes in one project?
Ans: use the global variable, default_theme.

How can prevent or restrict multiple login in drupal
Ans: Use the Session Limit Module –

While doing the migration how date will be migrated. (is there any with date migration)
Ans: There will be issue with date format. It takes only unix time format.

How can we set the region in drupal theme?
Ans: You can set the regions in file. Following is the example:
regions[header] = Header
regions[content_header] = Content Header
regions[content] = Content
regions[sidebar_second] = Right sidebar

How can we improve the Drupal site performance?
Ans: Use PHP APC, Use memcache, Use the Varnish. Most important module – Use the Boost module. Use Views Cache.
For very high traffic, Use the CDN module. Use the Block Cache.

Which database storage engine is used in d6 and d7?
Ans: Drupal 6 uses the MYISAM and Drupal 7 uses the INODB

Which modules are added in d7 core modules?
Ans: Following modules are added in d7 core.
Entity API
Another API module which is required by many other modules. This module extends core’s entities in lots of useful ways.
Entity Reference
Create relationships between any entities. This is a superior replacement to Node Reference and User Reference in Drupal 6.
Adding media to content was tricky before the media module. This should be installed on every Drupal 7 site.

What is left join and right joins?
For the sake of this example, lets say you have 100 students, 70 of which have lockers. You have a total of 50 lockers, 40 of which have at least 1 student.

INNER JOIN is equivalent to “show me all students with lockers”.
Any students without lockers, or any lockers without students are missing.
Returns 70 rows

LEFT OUTER JOIN would be “show me all students, with their corresponding locker if they have one”.
This might be a general student list, or could be used to identify students with no locker.
Returns 100 rows

RIGHT OUTER JOIN would be “show me all lockers, and the students assigned to them if there are any”.
This could be used to identify lockers that have no students assigned, or lockers that have too many students.
Returns 80 rows (list of 70 students in the 40 lockers, plus the 10 lockers with no student)

FULL OUTER JOIN would be silly and probably not much use.
Something like “show me all students and all lockers, and match them up where you can”
Returns 110 rows (all 100 students, including those without lockers. Plus the 10 lockers with no student)

CROSS JOIN is also fairly silly in this scenario.
It doesn’t use the linked “lockernumber” field in the students table, so you basically end up with a big giant list of every possible student-to-locker pairing, whether or not it actually exists.
Returns 5000 rows (100 students x 50 lockers). Could be useful (with filtering) as a starting point to match up the new students with the empty lockers.

How to create the table using module?
Ans: Use following code:
* Implements hook_schema().
function module_name_schema() {
$schema[‘module_name’] = array(
‘fields’ => array(
‘type’ => array(‘type’ => ‘varchar’, ‘length’ => 15, ‘not null’ => TRUE, ‘default’ => ‘node’),
‘id’ => array(‘type’ => ‘int’, ‘unsigned’ => TRUE, ‘not null’ => TRUE, ‘default’ => 0),
‘module_name’ => array(‘type’ => ‘varchar’, ‘length’ => 255, ‘not null’ => TRUE, ‘default’ => ”)
‘primary key’ => array(‘type’, ‘id’),

return $schema;

* Implements hook_uninstall().
function module_name_uninstall() {
// Clear variables


How to update table using module?
Ans: You can check the following code:
* Implements hook_update_n().
function module_name_update_6200() {
$ret = array();

if (db_column_exists(‘module_name’, ‘id’)) {
return $ret;

db_create_table($ret, ‘module_name_temp’, array(
‘fields’ => array(
‘type’ => array(‘type’ => ‘varchar’, ‘length’ => 15, ‘not null’ => TRUE, ‘default’ => ‘node’),
‘id’ => array(‘type’ => ‘int’, ‘unsigned’ => TRUE, ‘not null’ => TRUE, ‘default’ => 0),
‘module_name’ => array(‘type’ => ‘varchar’, ‘length’ => 255, ‘not null’ => TRUE, ‘default’ => ”)
‘primary key’ => array(‘type’, ‘id’),

$ret[] = update_sql(‘INSERT INTO {module_name_temp} (id, module_name) SELECT nid, module_name FROM {module_name}’);

db_rename_table($ret, ‘module_name’, ‘module_name_old’);

db_rename_table($ret, ‘module_name_temp’, ‘module_name’);

$display_settings = variable_get(‘module_name_display’, array());
foreach ($display_settings as $type) {
if ($type) {
variable_set(‘module_name_type_’ . $type . ‘_showfield’, 1);

return $ret;

How to drop the table using module?
Ans: Use db_drop_table method in install file

Which hooks you used and what is the purpose of using the those hooks?
Ans: You need to give this answer

How to create install script for drupal module and create tables

Ans: Check answer here

What is responsive theme?

Ans: A responsive theme (as the one used for this website), is an approach to web development that allows a website to break itself down smoothly across multiple monitor sizes, screen resolutions, and platforms, be it a computer, tablet or mobile device. It allows the developer to create a site that is optimized for each platform, both in navigation, readability and load time.

As you can see when resizing the window (if you are viewing this site on a computer), the layout of the page shifts depending on the size of the screen; with different layouts for content depending on viewing area. Themes (or layouts) such as this, allow for a single site and single look to the site, to be viewed on various devices without the need for additional themes or resizing by the user.

How to create the responsive theme?
Ans: You can check the following URL:

What is difference between innodb and myIsam?
Ans: First major difference I see is that InnoDB implements row-level lock while MyISAM can do only a table-level lock. You will find better crash recovery in InnoDB. However, it doesn’t have FULLTEXT search indexes, as does MyISAM. InnoDB also implements transactions, foreign keys and relationship constraints while MyISAM does not.

What is difference between update and alter query?
Ans: ALTER is a DDL (Data Definition Language) statement. Whereas UPDATE is a DML (Data Manipulation Language) statement. One is used to update the structure of the table (add/remove field/index etc). Whereas UPDATE is used to update data.

What is purpose or use of .htaccess file?
Ans: File_HtAccess provides common methods to create and manipulate Apache / NCSA style .htaccess files. These files together with accompanying password files are used to protect webserver directories. Since File_HtAccess does not provide any means to manipulate or create password files you should use it together with File_Passwd.

What is use of substr and strstr function?
Ans: strstr — Find the first occurrence of a string. substr — Return part of a string.

Can we include one php file multiple times?
Ans: Yes.

What is contextual filter?
Ans: , contextual filters were called arguments in Views and a lot of documentation, tutorials and Views-compatible modules still use that term. If you see the term argument, it should be interpreted either as a contextual filter, or the value provided to a contextual filter.

How to use the contextual filter?
Ans: The classic example of how contextual filter values are provided to views is by the view path. If a view has the path, the URL will call the view along with two values for contextual filters (in this case story and 22). But there are more ways of providing contextual filter values. These are discussed in Chapter about Page manager and Panels.

What is taxonomy?
Ans: Taxonomy, a powerful core module, gives your sites use of the organizational keywords known in other systems as categories, tags, or metadata. It allows you to connect, relate and classify your website’s content. In Drupal, these terms are gathered within “vocabularies.” The Taxonomy module allows you to create, manage and apply those vocabularies.

New under Drupal 7 is the ability to add taxonomy fields to vocabularies and terms.

How to update the drupal?
Ans: Easiest way is use update.php file. If you installed the drush then you can use the following command “drush pm-update”. Do not forget to take file and mysql backup before update.

if we delete the page.tpl.php then drupal site will work or not?
Ans: Yes. will work. It will check for node.tpl.php file.

How to delete drupal cache manually through mysql

Ans: Check answer here

Did you written the query in D7 for your module?
Ans: Check following URL

Do you have profile on drupal site? Do you write the comments on Drupal site?
Ans: If you have drupal profile then say yes. If not then create profile now.

Did you contributed the drupal site (any module)?
Ans: Try adding some patches or modules to drupal.

What modules do you always recommend to your clients?
Ans: Views, Panels, Ctools, Token, Pathauto, Webform, Rules, Features, Strongarm, Date, view slideshow, Drush, Entity Reference, QuickTab, Libraries, Google Analytics, Display Suite, Context, Module Filter, CSS Injector, Diff

Which files are required for Creating the Drupal Module?
Ans: and MODULENAME.module file are required for creating the module.

Which files are required for Creating the Drupal Theme?
Ans: .info (declares the theme features) and page.tpl.php (defines the layout)

How can we add the new Menu to Drupal Admin section?
Ans: Use following:
Navigate to administer > site building > menus
Select the Add menu tab item
For the title enter Example menu and select to return to the menu list view

How does caching work in Drupal?
Ans: Use this link

What is the use of taxonomy and vocabulary in Drupal?
Ans: Taxonomy, a powerful core module, gives your sites use of the organizational keywords known in other systems as categories, tags, or metadata. It allows you to connect, relate and classify your website’s content. In Drupal, these terms are gathered within “vocabularies.” The Taxonomy module allows you to create, manage and apply those vocabularies.

How to interact with Drupal search system ?
Ans: The search module lets users search for specific content on your site. You can search both for users and for particular words. When you are on the “content” tab of Search, you will be able to search for words appearing in the default rendering of node content on your site, which would include the default rendering of any CCK fields, Location fields, Taxonomy, etc., as well as comments. When you are on the “users” tab of Search, you will be able to search the user names of registered users on your site, and if you have sufficient permissions, also their email addresses.

What are hooks in Drupal?
Ans: hooks are implemented in modules and you can read about the core hooks here: Basically they provide a way for a module to extend the functionality of another module. For example the ‘node’ module provides the core features of a node (content type). You can use CCK or a custom module to create a custom content. You can also use the nodeapi hook to extend the functionality of any content type. The are core hooks for working with node, users, taxonomy and more. Contributed module may also add addition hooks your module can implement.

How can add the Captcha in registration page for drupal?
Ans: Use the captcha and recaptcha module.

For Image slider which modules are required in Drupal?
Ans: use Views slideshow, nivo slider modules. there are other modules also.

Can I use Drupal on the command line?
Ans: Use drush.

What does Views do and how do you use it?
Ans:You need Views if:
You like the default front page view, but you find you want to sort it differently.
You like the default taxonomy/term view, but you find you want to sort it differently; for example, alphabetically.
You use /tracker, but you want to restrict it to posts of a certain type.
You like the idea of the ‘article’ module, but it doesn’t display articles the way you like.
You want a way to display a block with the 5 most recent posts of some particular type.
You want to provide ‘unread forum posts’.
You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of “Month, YYYY (X)” where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month.
Views can do a lot more than that, but those are some of the obvious uses of Views.

How do you handle upgrades?
Ans: use update.php or drush command (pm-update)

Which module is required for Google, Facebook, twitter login?

Which module can be used for E-commerce?
Ans: Use ubercart module

If I want to add the extra fields in registration field then what should we do?
Ans: Use profile module. In drupal 7 Profile is in core.

How can we modify the form validation of Drupal?
Ans: Use form alter hook and use this “‘#required’ => TRUE”

Which are the core required modules in drupal 6.x
Ans: Check this URL :

How to enable clean urls in drupal ?
Ans: apache support is needed for this. Then enable from admin.

What is PDO?
Ans:PDO is an acronym for PHP Data Objects. PDO is a lean, consistent way to access databases. This means developers can write portable code much easier. PDO is not an abstraction layer like PearDB. PDO is a more like a data access layer which uses a unified API (Application Programming Interface).

What is a patch in Drupal and how will we apply patch in drupal?
Ans:A patch is a file that consists of a list of differences between one set of files and another. All code changes, additions, or deletions to Drupal core and contributed modules/themes between developers are done through patches. The differences are presented in a structured, standard way, which means that a program (also named patch) can be used to apply the changes to another copy of the original file.

How to post videos from mobile to Drupal website?
Ans: Use the video module. For bigger sites use brightcove module.
This is paid service.

List the SEO modules available in Drupal.
Ans: Use following modules
Nodewords/ Meta tags
Service links
Google analytics
Related Links
Search 404
Site map
Url list

List the modules required for building a social networking website in Drupal.
• Advanced Forum
• Advanced Profile Kit
• Application Toolbar (Appbar)
• Author Pane
• Buddylist2 Package
• Buddylist: list your social network
• CiviCRM: manage community contacts, relationships, and activities
• CiviNode and CiviNode CCK: Tools For Integrating CiviCRM Contacts Into Drupal Content
• Comment Notify
• FOAF: friends of a friend
• Facebook-style Statuses
• Family: Record, display, and analyze genealogical data.
• Flag Friend
• Friend
• FriendList
• Front: Show group membership and events
• Gigya Socialize Module
• Invite: send invitations to join your site
• Notice Feed
• Organic Group
• Profile Setup
• Radioactivity
• Sports Pickem
• Tellafriend Node
• User Invite
• User Relationships
• UserTag:Tag …

How To Define New Regions (Sidebar,Header, footer) in Drupal ?
Ans:ADD this code in its entirety to the bottom of your template.php file:

Explain me User, Permission, Role in drupal?

Which ORM is used in Drupal 7?
Ans: Doctrine is the ORM.

Which Design Pattern used in Drupal?
Ans: Singleton Design pattern is used in Drupal.

What is the use of features module?
Ans: The features module enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together satisfy a certain use-case.

Features provides a UI and API for taking different site building components from modules with exportables and bundling them together in a single feature module. A feature module is like any other Drupal module except that it declares its components (e.g. views, contexts, CCK fields, etc.) in its .info file so that it can be checked, updated, or reverted programmatically.

Did you used the Panel module? If yes then what is the use of that?
Ans: The Panels module allows a site administrator to create customized layouts for multiple uses. At its core it is a drag and drop content manager that lets you visually design a layout and place content within that layout. Integration with other systems allows you to create nodes that use this, landing pages that use this, and even override system pages such as taxonomy and the node page so that you can customize the layout of your site with very fine grained permissions.

What is the use of Ctools module?
Ans: This suite is primarily a set of APIs and tools to improve the developer experience. It also contains a module called the Page Manager whose job is to manage pages. In particular it manages panel pages, but as it grows it will be able to manage far more than just Panels.

For Drupal module development code review which module can be used?
Ans: Use the the coder moduble

Which Drush commands you use while development?
Ans: Following drush commands are use useful while development.
Drush cc – clear cache
pm-disable (dis) Disable one or more extensions (modules or themes).
pm-download (dl) Download projects from or other sources.
pm-enable (en) Enable one or more extensions (modules or themes).
pm-info (pmi) Show detailed info for one or more extensions (modules or themes).
pm-list (pml) Show a list of available extensions (modules and themes).
pm-refresh (rf) Refresh update status information.
pm-releasenotes Print release notes for given projects.
pm-releases (rl) Print release information for given projects.
pm-uninstall Uninstall one or more modules.
pm-update (up) Update Drupal core and contrib projects and apply any pending database updates (Same as pm-updatecode + updatedb).
pm-updatecode (upc) Update Drupal core and contrib projects to latest recommended releases.

For better search what we can do in Drupal 7?
Ans: Use the Solr module

How can Improve the Drupal cache and logging?
Ans: Use the Mongodb module

wordpress to drupal migration using drush commands made easy

I migrated some wordpress sites into drupal very easily.  With drupal 7 it is very easy. There are some drupal modules which are really helpful to migrate the wordpress posts and pages in drupal site. Drupal is more famous and usable in people and developers. Many clients demands for doing there site in drupal. With my simple steps you can easily migrate the wordpress sites to drupal.

wordpress to drupal migration

If you are drupal developer then you just need to use following drush commands with plain drupal installation. Many people are moving there sites to drupal now.

Following commands will install all related drupal modules which are helpful to do the wordpress to drupal migration.

#drush pm-enable migrate_extras -y
#drush pm-enable wordpress_migrate -y
#drush pm-enable pathauto -y
#drush pm-disable ckeditor -y
#drush pm-enable media -y
#drush pm-enable token -y
#drush pm-enable imce -y

Above commands will download the module and install it in your drupal application. Modules will be activated also. Now you just need to import your wordpress blog into drupal application.

Login to drupal admin and go to “admin/content/wordpress”.  Add the wordpress URL, username and password. Then click on “Import wordpress blog” button. That sit.

how to show code snippet in drupal post or page

Wanted to show code snippet in drupal website then you can use following modules for achieve this functionality.

I tried to display php code and html tag in a tutorial.

how to show code snippet in drupal post or page

First simple option is,

Use the tag to post the php code or html code and display in the post
as I have done below


There are nice modules which are useful for showing the code sample in post.

Code Filter
This module provides a simple text format (input filter) that handles and tags so that users can post code without having to worry about manually escaping < and > characters with < and >

Syntax highlighter
This module integrates the SyntaxHighlighter Javascript Library into Drupal for source code list syntax highlighting within any Drupal contents.

GeSHi Filter for syntax highlighting
The GeShi Filter module provides a filter for source code syntax highlighting for a wide range of languages.

Source code can be entered with for example ... or…. Starting from version 5.x-2.0 it is also possible to define your own generic and language specific tags (e.g.) or to work with square bracket style tags (e.g.

). Automatically adding line numbers is possible too with for example

Install Drupal using Drush command only

Every Drupal developer knows about drush. If you did not installed drush then use the following article for installing drush. Here in this article I am going explain you about install drupal empty project in only two steps.


For setup the empty drupal project setup use following command

#drush dl drupal-7
Project drupal (7.28) downloaded to /home/purab/drupal-7.28.                                                                                                       [success]
Project drupal contains:                                                                                                                                           [success]
– 3 profiles: testing, minimal, standard
– 4 themes: stark, seven, bartik, garland
– 47 modules: drupal_system_listing_incompatible_test, drupal_system_listing_compatible_test, poll, rdf, statistics, user, taxonomy, translation, tracker, node,
contact, syslog, contextual, profile, overlay, forum, blog, book, system, aggregator, path, comment, help, simpletest, trigger, menu, dashboard, search, locale,
field_ui, shortcut, options, number, field_sql_storage, text, list, field, php, color, toolbar, filter, update, dblog, file, block, image, openid

#cd drupal-7.28

#drush site-install standard –account-name=admin –account-pass=admin –db-url=mysql://mydbusername:’pass@123’@localhost/mydbname

You are about to create a sites/default/files directory and create a sites/default/settings.php file and DROP all tables in your ‘marketplace’ database. Do you want to continue? (y/n): y
Warning: Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1
Starting Drupal installation. This takes a few seconds …                                                                                                         [ok]
Installation complete.  User name: admin  User password: admin

after this you can check project in browser.


Update url alias of user nodes on change of drupal username

One of our client want functionality to change username in edit profile which is easy. We are using pathauto module for pretty URL in Drupal7.
I faced two issues when changing username. which are explained here..

First Issue

We are using username paths (/users/[username]). After changing a username the url alias doesn’t change and the user edit page doesn’t have an option to change it manually.

Second Issue

We are using username before nodes urls. for after changing username Node uel alias does not change automatically.

Solution (for first issue):
For fist issue I used rules modeuls and created following rule:

You can create rule using following export rule.

{ "rules_change_user_url_alias" : {
    "LABEL" : "Change user URL alias",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "path" ],
    "ON" : [ "user_update" ],
    "IF" : [
      { "NOT data_is" : { "data" : [ "account-unchanged:name" ], "value" : [ "account:name" ] } }
    "DO" : [
      { "path_alias" : { "source" : "user\/[account:uid]", "alias" : "member\/[account:name]" } }

Solution (for Second issue):
For second issue, I written custom code as follows:
I used user_update hook for solving this issue.
You just need to put following code in your custom module. It will find all nodes of editing user (logged in user) and update url alias.

 * On user update call this method for updating the node url in url_alias
function MYMODULE_user_update(&$edit, $account, $category) {
    //getting all nodes
    $nodes = get_user_node_by_type('custom_node_type',$account->uid);
    //loop for all nodes of logged in User
    if(!empty($nodes)) {
        foreach ($nodes as $key => $node) {
            //load path auto module
            if(module_load_include('inc','pathauto','pathauto') !== FALSE) {
                if (function_exists('pathauto_cleanstring')) {
                //generates clear url title from node title
                $currnt_page_title_alias = pathauto_cleanstring($node->title); // define in file.
                //generate new url for selected node
                // echo 'node/'.$node->nid;die;
                $query = db_query("select from {url_alias} AS u WHERE u.source = 'node/$node->nid'");         
                $result = $query->fetchAll();
                    //If url alias found for node than update the alias
                    if(!empty($result)) {
                        db_query("UPDATE {url_alias} AS u SET u.alias = '$new_url' WHERE u.source = 'node/$node->nid'");

 * Return User nodes based on UID and node type
function get_user_node_by_type($node_type, $uid){
  $nodes = array();
  $nids = db_query('SELECT nid FROM {node} WHERE uid = :uid AND type = :type', array(':uid' => $uid, ':type' => $node_type))->fetchCol();
  if (!empty($nids)) {
    $nodes = node_load_multiple($nids);    
  return $nodes;

Above code will solve my problem. When I edit my username, It collects all nodes which are created by that user and update the url_alias of nodes.

Install drush on CentOS using command line with simple steps

Drush is great native application for development of drupal project. I really like to use this tool in every project. There are some good steps to install drush on Linux or windows environment. I recently installed drush on my centos machine. Here are those steps:

Commands has been highlighted in blue color.

[root@ap107 purab]# wget
–2016-04-21 11:50:43–
Connecting to||:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 5264426 (5.0M) [application/octet-stream]
Saving to: “drush.phar”

100%[===========================================================================================================================================================>] 5,264,426    221K/s   in 65s

2016-04-21 11:51:50 (78.5 KB/s) – “drush.phar” saved [5264426/5264426]

[root@ap107 purab]# php drush.phar core-status
PHP configuration      :  /etc/php.ini
PHP OS                 :  Linux
Drush script           :  /home/purab/drush.phar
Drush version          :  8.0.5
Drush temp directory   :  /tmp
Drush configuration    :
Drush alias files      :

[root@ap107 purab]# chmod +x drush.phar

[root@ap107 purab]# mv /usr/local/bin/drush /usr/bin/drush
[root@ap107 purab]# drush init
Copied example Drush configuration file to /root/.drush/drushrc.php                                                                                                                       [ok]
Copied example Drush bash configuration file to /root/.drush/drush.bashrc                                                                                                                 [ok]
Copied Drush completion file to /root/.drush/                                                                                                                            [ok]
Copied example Drush prompt file to /root/.drush/                                                                                                                          [ok]
# Include Drush bash customizations.
if [ -f “/root/.drush/drush.bashrc” ] ; then
source /root/.drush/drush.bashrc

# Include Drush completion.
if [ -f “/root/.drush/” ] ; then
source /root/.drush/

# Include Drush prompt customizations.
if [ -f “/root/.drush/” ] ; then
source /root/.drush/

Append the above code to /root/.bashrc? (y/n): y
Updated bash configuration file /root/.bashrc                                                                                                                                             [ok]
Start a new shell in order to experience the improvements (e.g. `bash`).                                                                                                                  [ok]
[root@ap107 purab]# drush

How to delete drupal cache manually through mysql

Some time I found some issues with Drupal site. When we make changes in javascript or in PHP code we need to clear the cache from Drupal site. One time I got really weird issue. I am not able to access my druapl admin also.

delete drupal cache manually through mysql

Then I found only one option which is I need to clear the cache from Drupal. Using Drupal admin panel we can easily delete the drupal cache but how can I delete the drupal cache manually. We can delete the Drupal cache through mysql also.


For that you need to use following mysql commands in phpmyadmin or through mysql command line.

[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]



DELETE FROM cache_filters;

DELETE FROM cache_menu;

DELETE FROM cache_page;

DELETE FROM watchdog;



above mysql commands will clear all the cache from drupal. If you want more drupal tutorials than visit here

create install script for drupal module and create tables

Drupal is most popular CMS in the world for creating the web application. For custom purpose we need to create the drupal modules. We need the custom tables for creating the drupal.

create install script for drupal module and create tables

create install script for drupal module and create tables
create install script for drupal module and create tables

In this article I will tell how you can create the sample drupal module with custom two table. When you activate the drupal module then tables which are defined in the module will be get installed. When you unactive the drupal module tables will get deleted from database.

For creating the drupal module three files are necessary and that as follow:

1. (you can use your module name

2. yourmodule.install

3. yourmodule.module

First .info file is important and in that file we will put module related information. file has following content.

; $Id$
name = My module
description = This module is to test the install feature
core = 6.x

For creating custom tables you can use following code in mymodule.install file.

function mymodule_schema() {
 $schema['mymodule_test'] = array(
 'description' =--> t('The base table for saved articles.'),
 'fields' => array(
 'id' => array(
 'description' => t('The primary identifier'),
 'type' => 'int',
 'unsigned' => TRUE,
 'not null' => TRUE),
 'uid' => array(
 'description' => t('The user identifier.'),
 'type' => 'int',
 'unsigned' => TRUE,
 'not null' => TRUE,
 'default' => 0),
 'name' => array(
 'description' => t('The name.'),
 'type' => 'varchar',
 'length' => '100',
 'not null' => TRUE,
 'not null' => TRUE),
 'primary key' => array('id'),

 $schema['mymodule_test1'] = array(
 'description' => t('The base table for saved articles.'),
 'fields' => array(
 'id' => array(
 'description' => t('The primary identifier'),
 'type' => 'int',
 'unsigned' => TRUE,
 'not null' => TRUE),
 'uid1' => array(
 'description' => t('The user identifier.'),
 'type' => 'int',
 'unsigned' => TRUE,
 'not null' => TRUE,
 'default' => 0),
 'name' => array(
 'description' => t('The name.'),
 'type' => 'varchar',
 'length' => '100',
 'not null' => TRUE,
 'not null' => TRUE),
 'primary key' => array('id'),

 return $schema;

function mymodule_install() {
 // Create my tables.

function mymodule_uninstall() {
 // Drop my tables.

.Module file is most important. In this file you can put the code which for you written the module. Now in this file Now I am giving you the sample menu code. mymodule.module file has following content.

function mymodule_menu() {

 $items['mymodule'] = array(
 'title' =--> 'mymodule View',
 'page callback' => 'mymodule_view',
 'access arguments' => array('access content'),

 return $items;

function mymodule_view()
 return 'test';


If you have some more doubts then please content me and comment on this article.

If you want more drupal tutorials than visit here