Next Tutorial

Drupal 7 Tutorial Part 19: Understanding Drupal 7 Content Types & Fields Concepts !

Drupal 7 Tips

How to create Virtual Hosts for Drupal Instance on Linux Ubuntu Local Machine

Submitted by anilsagar on Wed, 06/06/2012 - 11:46

Hi Guys,

Instead of using localhost/sitename if you would like to use domains such as local.sitename.com then follow below process. It will be helpful to avoid basepath in rich text editor links and can avoid basepath issues if any !

Step 1:

            Assume your code resides at /var/www/drupalsite.

Step 2:

           You can access your site using http://localhost/drupalsite.

Step 3: 

How to alter Javascript Files loaded on a Page in Drupal 7 ?

Submitted by anilsagar on Wed, 05/30/2012 - 12:42

Dear Drupalers,

If you would like to remove some of the Javascript files loaded on a page or Swap the Javascript files with some other files dynamically on page load then you need to learn about hook_js_alter.

Hook_js_alter allows to change the Javascript files on different pages. For Example if you would like to avoid a particular Javascript file on Home Page or any other page you can use this hook to alter list of Javascript files loaded on Page.

For more information http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_js_alter/7

 

Difference between hook_boot and hook_init

Submitted by anilsagar on Wed, 11/02/2011 - 23:30

Hi Drupalers,

There are some differences between hook_boot and hook_init although they seems equal. Let's check it out.

How to verify current page is Front page in Drupal using code

Submitted by anilsagar on Mon, 10/17/2011 - 12:31

Hi Drupalers,

Call function drupal_is_front_page() function in drupal to determine current page is home page or any other page.

If it returns true then it is front page, else you are in some other page other than front page / home page.

 

<?php

$flag = drupal_is_front_page();

if ($flag) {

  drupal_set_message("Welcome to front page of this site.");

else {

   drupal_set_message("Now you are in page other than front page.");

}

?>

How to find which modules are implementing a hook in Drupal 7

Submitted by anilsagar on Wed, 08/10/2011 - 10:43

Many of you know, hooks are the way to extend drupal. Each and every module implement a hook to extend drupal functionality. For, debugging purpose or for any other reason if you want to know which are modules implementing a certain hook you can use below function.

<?php

$modules = module_implements($hook, $sort = FALSE, $reset = FALSE);

How to resolve WSOD (White Screen Of Death) error in drupal ?

Submitted by anilsagar on Fri, 08/05/2011 - 10:40

Most of the times when you end up with some syntax errors you will see wsod white screen of death in drupal sites. To find the exact location of error copy paste below code in index.php file immediately after <?php tags to see the error location instead of wsod. Please find the code below.

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

How do i debug errors in Drupal ?

Submitted by anilsagar on Thu, 08/04/2011 - 22:37

You can debug errors using devel module. http://drupal.org/project/devel . Install this module only in development environment. Strictly disable this module in production (live) sites to avoid performance related problems.

Alternatively, you can use xdebugger with eclipse. Find tutorial here to install this. http://www.anilsagar.com/blog/debug-drupal-using-xdebug-eclipse-and-wamp

How to add google analytics javascript code to Drupal Site ?

Submitted by anilsagar on Thu, 08/04/2011 - 18:15

Install and Use google analytics module http://drupal.org/project/google_analytics provided by drupal.org community to easily install Google Analytics Javascript Code to your drupal site.

After installing this module you have full flexibilty to enable or disable the Google Analytics JS code in specific pages of your drupal site.

Stay tuned for more drupal tips :-)

How to follow drupal coding standards ?

Submitted by anilsagar on Thu, 08/04/2011 - 18:05

As a programmer most of them find difficult to use drupal coding standards mentioned here. http://drupal.org/coding-standards.

Install and use coder module http://drupal.org/project/coder which does an excellent job to identify and suggest drupal coding standards in your custom modules.

Stay tuned to learn more tips daily :-)

Make sure Javascript Aggregation, CSS aggregation, Cache pages settings enabled @ performance page.

Drupal 6 you can find this page @: admin/settings/performance

Drupal 7 you can find this page @: admin/config/development/performance

Syndicate content
©2010 AnilSagar. All rights reserved. Drupal theme by Kiwi Themes.