Web Development Tips

Video download problem in drupal 6

Posted by: slvramesh on: October 22, 2009

Problem:

When am i trying to download video in drupal 6 (video module) its not working. I have to spend one hours and find the solution.

Step 1:

Replace the code line number 104 to 120 from the video.module file.

Old Code

if (arg(0) == ‘node’ && is_numeric(arg(1))) {
if ($node = node_load(arg(1)) and $node->type == ‘video’) {

//enable the download tab only if it is supported
if (video_support_download($node)) {

$menu_type = (variable_get(‘video_displaydownloadmenutab’, 1)) ? MENU_LOCAL_TASK : MENU_CALLBACK;
$items['node/'.$node->nid.'/download'] = array(
‘title’ => ‘Download’,
‘page callback’ => ‘video_download’,
‘page arguments’ => array($node),
‘access arguments’ => array(‘access video’) && node_access(‘view’, $node, $user->uid),
‘weight’ => 5,
‘type’ => $menu_type);
}
}
}

New Code:

$items['video/download/%node'] = array(
‘title’ => ‘Download’,
‘page callback’ => ‘video_download’,
‘page arguments’ => array(2),
‘access arguments’ => array(‘access video’),
‘type’ => MENU_CALLBACK);

Step 2:

Replace the menu link cod, Find the below code from video.module file

‘href’ => “node/$node->nid/download”,

and replace the below code

‘href’ => “video/download/%node”,

Now remove the cache file from your drupal site using the admin user.

Now its working fine.

Error when install libsdl in mac os x leopard

Posted by: slvramesh on: October 15, 2009

Problem:

Error: Target org.macports.checksum returned: Could not open file: /opt/local/var/macports/distfiles/libsdl/1.2.14_6/SDL-1.2.14.tar.gz

Error: The following dependencies failed to build: libsdl libtheora libvorbis schroedinger liboil glib2 x264

Error: Status 1 encountered during processing.

Solution:

First clean your existing libsdl if you already tried out

$ sudo port clean –dist libsdl

Next install new

$ sudo port install libsdl

Best Table Grid websites

Posted by: slvramesh on: August 28, 2009

I found the beautiful table grid websites around the internet. It is fantastic for website development lover.

1.) http://www.pabloaravena.info/mytablegrid/

WordPress problem: When you add new post in wordpress blogs it shows this error like

– Your attempt to edit this post: “tst12323″ has failed. –

Solution:

This is not final solution. This is got my experiance in wordpress.

1. Check you pluings. If you install “WP Super Cache” plugin in ISS Machine this is not working properly. Because IIS did not support mod_rewritte and “WP Cache and Super Cache enabled“. So you chnage the “Wp super cache status”.

Steps to change “wp super cache status”

1. Login wordpress admin

2. Click the setting menu

3. Cllick “Wp Super cache” menu

4. In “WP Super Cache Status” area, Click the radio button “HALF ON Super Cache Disabled, only legacy WP-Cache caching”.

5. And click update status button.

Now you may try to add new post. It is working properly…

It you getting any troble on this, feel free… ping me..

How to set Permalink in wordpress bogs on windows machine

Posted by: slvramesh on: April 7, 2009

Setting permalink in wordpress blogs is a huge difficult to find in learning level.  It is very simple.  I was found that the solution after five months.  Your follow the simple steps it will woking fine.

Steps to set permalink in wordpress blogs on IIS.

1. Open your php.ini file in notepad or any text editor.

2. Find the word “cgi.fix_pathinfo”.

3. Uncomment the statement [ cgi.fix_pathinfo="1" ]

4. Now restart your IIS server

5. Login your worpress blogs admin window and set the permalinks settings.

Now go and view your blog site. The permalik working perfectly…

Thumbnail Maker

Posted by: slvramesh on: March 12, 2008

Thumbnail Maker

//define a maxim size for the uploaded images
define (“MAX_SIZE”,”1000″);
// define the width and height for the thumbnail
// note that theese dimmensions are considered the maximum dimmension and are not fixed,
// because we have to keep the image ratio intact or it will be deformed
define (“WIDTH”,”75″);
define (“HEIGHT”,”75″);

// this is the function that will create the thumbnail image from the uploaded image
// the resize will be done considering the width and height defined, but without deforming the image
function make_thumb($siname,$tiname,$new_w,$new_h)
{
//get image extension.
$ext=getExtension($siname);
//creates the new image using the appropriate function from gd library
if(!strcmp(“jpg”,$ext) || !strcmp(“jpeg”,$ext))
$src_img=imagecreatefromjpeg($siname);

if(!strcmp(“png”,$ext))
$src_img=imagecreatefrompng($siname);

//gets the dimmensions of the image
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);

// next we will calculate the new dimmensions for the thumbnail image
// the next steps will be taken:
// 1. calculate the ratio by dividing the old dimmensions with the new ones
// 2. if the ratio for the width is higher, the width will remain the one define in WIDTH variable
// and the height will be calculated so the image ratio will not change
// 3. otherwise we will use the height ratio for the image
// as a result, only one of the dimmensions will be from the fixed ones
$ratio1=$old_x/$new_w;
$ratio2=$old_y/$new_h;
if($ratio1>$ratio2) {
$thumb_w=$new_w;
$thumb_h=$old_y/$ratio1;
}
else {
$thumb_h=$new_h;
$thumb_w=$old_x/$ratio2;
}

// we create a new image with the new dimmensions
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);

// resize the big image to the new created one
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);

// output the created image to the file. Now we will have the thumbnail into the file named by $filename
if(!strcmp(“png”,$ext))
imagepng($tiname,$filename);
else
imagejpeg($tiname,$filename);

//destroys source and destination images.
imagedestroy($tiname);
imagedestroy($src_img);
}

// This function reads the extension of the file.
// It is used to determine if the file is an image by checking the extension.
function getExtension($str) {
$i = strrpos($str,”.”);
if (!$i) { return “”; }
$l = strlen($str) – $i;
$ext = substr($str,$i+1,$l);
return $ext;
}

thumbnail_maker($source_image_name,$thumb_image_name,WIDTH,HEIGHT);

Custom Trim Function – javascript

Posted by: slvramesh on: January 22, 2008

In JavaScript, It is difficult to remove the white spaces for a string. JavaScript is mainly used for form validation. The users may make mistakes while submitting the form As a developer we will trim the spaces from user input. The custom trim function used to remove the white space in both side.

  // Remove leftside whitespacesfunction LeftTrim( value ) {
var re = /\s*((\S+\s*)*)/;
return value.replace(re, “$1″);
}

// Remove right side whitespaces

function RTrim( value ) {
var re = /((\s*\S+)*)\s*/;
return value.replace(re, “$1″);
}

// Remove left and right side whitespaces

function trim( value ) {
return LTrim(RTrim(value));
}

Rounded Corner Without Image

Posted by: slvramesh on: December 28, 2007

I have create rounded corder box without image.

Rounded Corner Without Image

Here is the coding. Copy below code and paste text editor and save .html file and view your browser.

<!– css –>

 <style type=”text/css”>
.test{background:#fff;color:#222;margin-left:9px;margin-right:9px;margin-top:5px;margin-bottom:5px;}
.container {background:#ccc; color:#fff; margin:0 15px;width:500px;position:relative;top:100px;left:100px;}
.rtop, .rbottom{display:block;background:#fff;}
.rtop *, .rbottom *{display: block;height: 1px;overflow: hidden;background:#ccc;}

.r1{margin: 0 5px}
.r2{margin: 0 3px}
.r3{margin: 0 2px}
.r4{margin: 0 1px; height:2px}

.rctop{display:block;background:#ccc;}

.rctop *{display: block;height: 1px;overflow: hidden;background:#fff;}

.rc1{margin: 0 5px}
.rc2{margin: 0 3px}
.rc3{margin: 0 2px}
.rc4{margin: 0 1px; height: 2px}

</style>

<!– html code –>

<div class=”container”>
 <b class=”rtop”><b class=”r1″></b> <b class=”r2″></b><b class=”r3″></b><b class=”r4″></b></b>
 <div class=”test”><b class=”rctop”><b class=”rc1″></b><b class=”rc2″></b><b class=”rc3″></b>
  <b class=”rc4″></b>
 </b>
 <div class=”test”>
  Rounded corner
  <br>
  Where The Rounded Corners Don’t Work
  <br>
  <br>
   You can’t use this exact style with a fixed height or with padding on the container
  <br>
   element. But you can solve that problem by creating a second container element that
  <br> assigns your height or padding.
 </div>
 <b class=”rctop”><b class=”rc4″></b><b class=”rc3″></b><b class=”rc2″></b><b class=”rc1″></b></b>
 </div><b class=”rbottom”><b class=”r4″></b><b class=”r3″></b><b class=”r2″></b><b class=”r1″></b>
 </b>
</div>