18+
votes
597 views

The password is failed to login because special character symbol like “$”(dollar sign) is considered to be special character in Linux.
drush upwd USERNAME --password="PASSWORD"

This command is actually running for Linux in which some special characters always needs to be escaped with “\”. So if you try the password:

 drush upwd root --password="S$1gma"

The above password will never work, to make the above password work you need to escape it...

Read More
19+
votes
2029 views

Settings file protection by password encryption

Settings.php was criticized for storing the plain text MySQL username and password. This procedure will let us remove the username and password from the settings.php and let us put that credentials outside of the website directory and store into another folder which can be taken care by security team or server managing people.

To do this, include a line at the top of settings.php file:

require_once '../...
Read More
23+
votes
730 views

By using the -r parameter we can run a script in-line.

php -r "require 'mylocation.php'; callmyfunc(143);"

where -r Run PHP without using script tags <?..?>

The above line will call callmyfunc() function with numeric argument 143 inside a mylocation.php file.
To run the above command you chould be in the directory where mylocation.php resides.

http://php.net/manual/en/features.commandline.options.php...

10+
votes
909 views

To count total number of directories within specific directory you have to go to one step back from the directory you want to count.
For example you have to count number of modules in modules folder on path /sites/all/modules. First navigate to folder /sites/all and then run the below command :

ls -l modules | grep -c ^d 

where "modules" is the name of the folder inside which you need to count directories.

34+
votes
1027 views

You can use two solutions for this but avoiding the 2nd solution with arg() function is better according to Drupal docs. You should arg() function wherever possible because resulting code is hard to read.

1) Use menu_get_object function

$term = menu_get_object('taxonomy_term', 2);
if ($term) {
  // User is on a taxonomy term page
}

2) Use arg() function

if (arg(0) ==  "taxonomy" && arg(1) == "term" &...
Read More
26+
votes
1034 views

If you want to add small JS without creating a new JS file, you can create a module and put the below code in your custom .module file.

drupal_add_js(
  '(function ($) {
// You can write here anything you like to perform. 
 alert("this is test"); })(jQuery);',
  array(
    'type' => 'inline',
    'scope' => 'footer',
    'group' => JS_THEME,
    'weight' => 5,
 )
);
10+
votes
824 views

For example we want to remove tag in this line :
techrappers is a very nice tech solution Website.

You can achieve it by two solutions :

1) $('b').contents().unwrap();

In the above Jquery line it will remove the tags and return you with simple string.

2) Or a much faster solution if you are unwrapping lots of a content

$("b").replaceWith(function() { return $(this).contents(); });

32+
votes
987 views

Here is the example function of inner join usage in Drupal 7. In this example we are fetching first and last name from database which we have already added in user entity.

 $matches = array();
 $select = db_select('users', 'u');
// Create inner join on table field_data_field_first_name
 $select->innerjoin('field_data_field_first_name', 'fn', 'fn.entity_id = u.uid'); 
// Create inner join on table field_data_field_last_name
 $select->innerjoin('...
Read More
10+
votes
974 views

Drupal 7 views 3 are designed to work on exposed filters, if and only if you use AJAX in your views block. That means you have to enable 
Use AJAX: YES  in you advanced section of Drupal views.

25+
votes
2236 views

This error occurs usually during a file upload and when you try to check the Drupal logs you will find error something like this -
"PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 2: INSERT INTO {file_managed}."

Usually if you remove the white spaces from your filename which you are uploading will solve this error . So for example if you have a filename like "tech rappers.jpg" then try changing the filename to "techrappers.jpg" or...

Read More