Drupal 7 release party

January 7, 2011 Leave a comment

Drupal 7 - Time to party!

Categories: Drupal

Happy New Year 2011

January 1, 2011 Leave a comment

Categories: 1

Truncate text using php

March 19, 2010 2 comments
function truncate($string, $length='' , $k = ''){
	if( $length == '') $length = 50;
	if( $k == '') $k = '...';
    settype($string, 'string');
    settype($length, 'integer');
    for($a = 0; $a < $length AND $a < strlen($string); $a++){
        $output .= $string[$a];
        if( strlen($string) > $length)
	   $output .= $k;
truncate text using php
$my_string = 'I am kajal Mondol.I live in Kolkata.';
echo truncate($my_string);
echo truncate($my_string,10);
echo truncate($my_string,10,',,,');

This will output:

 I am kajal Mondol.I live in Kolkata.
 I am kajal... 
 I am kajal,,, 

This function truncates a variable to a character length, default is 50.
‘…’ is the default text to append if truncation occurs.
Second parameter determines how many characters to truncate to.

Drupal 6 Simple Views Slideshow Setup In Aquia Marina

March 17, 2010 Leave a comment
Categories: Drupal

How to Add a Field to Drupal Contact form

March 9, 2010 5 comments

STEP 1 :

First you have to create a module. Create a folder into /sites/all/modules. Give the folder name your module name. Create a module file into the folder. Give the module a name. I have used “contactus.module”. In contactus.module file write the following lines. If you give different module name then the function name should be function yourmodulename_form_alter(&$form, $form_state).

#title    = Title of the input field.

#type     = Type of the input field (e.g. ‘textfield’ or ‘textarea’ etc.  )

#required = If the field is required then value will be true.

Unset function will disable the particular field. Here, in the example I unset copy field. You can re-order all the fields as per need. Just you have to the $ order array. For more information see http://api.drupal.org/api/function/hook_form_alter.


function contactus_form_alter(&$form, $form_state) {

$form['company'] = array(

'#title' => t('Your company'),

'#type' => 'textfield',


$form['phone'] = array(

'#title' => t('Your phone'),

'#type' => 'textfield',

'#required' =>'true',



// reorder the elements in the form to include the elements being inserted

$order = array('name','mail', 'subject', 'company', 'phone','message','submit');

foreach($order as $key => $field) {

$form[$field]['#weight'] = $key;


STEP  2: Now you have to create a info file.File name should be your modulename.info . Here I’ve used contactus.info. Into the .info file write the following lines.

name = “contactus”

description = “contact with us”

dependencies[] = contact

core = 6.x

php = 5.1

Categories: Drupal

Function to create GD thumbnail using Php

March 4, 2010 Leave a comment

Like This!

Add to Google Buzz

function thumbnail($src,$destimagename,$dimension)

if (preg_match("/gif/i",$name_extension))
if (preg_match("/jpg|jpeg/i",$name_extension))
if (preg_match("/png/i",$name_extension))

$thumb_w = $dimension;
$thumb_h = floor(($old_y/$old_x) * $dimension);





Categories: Php

PHP Headers and Popular Mime Types

March 3, 2010 Leave a comment


header('Content-type: application/atom+xml');


header('Content-type: text/javascript');

JPEG Image

header('Content-type: image/jpeg');


header('Content-type: application/pdf');


header('Content-type: text/xml');


header('Content-Type: application/rss+xml; charset=ISO-8859-1');


header('Content-type: text/css');
Categories: Php