Next Tutorial

Drupal 7 Tutorial Part 15: Drupal 7 Advanced Taxonomy Concepts

Drupal Tips

How To Login User Programatically In Drupal 6

Submitted by anilsagar on Tue, 12/06/2011 - 14:35

Hi,

If you are looking to automatically login Drupal user progrmatically here is the code for you.

$account = user_load($uid);

user_external_login($account);

 

Cheers,

Anil Sagar

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.");

}

?>

Confliction between Better messages and Ajax comments [Solved]

Submitted by anilsagar on Wed, 08/24/2011 - 15:16

Navigate to admin/settings/better-messages then add "ajax_comments/js" to Better Messages Visibility Setting and select shown on every page except the listed pages.

This will solve the conflict between Ajax Comments & Better Messages in drupal 6.

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 arrange node fields in node view with out using css ?

Submitted by anilsagar on Mon, 08/08/2011 - 15:31

Most of them feel very difficult when it comes to theming if they don't know CSS in drupal. For them, here comes the rescue module. Use Display Suite module to arrange your fields of node in the full view page. it's a very handy module if you dont know CSS.

Hi,

If you want to print images using imagecache presets in the custom drupal module development or programatically use below API function.


<?php print theme('imagecache', ‘my_preset’, $file_path, $alt, $title, $attributes); ?>

Replace my_preset with imagecache preset name.
$file_path with image path. like 'sites/default/files/xyz.jpg'
$attributes for img attributes like class etc...

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 :-)

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