Monday, September 26, 2011

Paypal - Add business logo to paypal check out page


Hi,

There can be scenarios where you need to show the business logo in the Paypal checkout page.

This is how it would look like:




Code

Well this can be easily achieved by adding the following hidden field in your paypal form:

Tuesday, August 30, 2011

Drupal - Simple captcha


Hi,


This article is about using custom captcha in Drupal. This one is a custom created module in Drupal. This is developed under Drupal 6.20 environment. I am sure if you get a feel of it you can modify it for other versions as well.

You can get the code from here.

This is how it would look like:


Code & Explanation:

After you have downloaded the module. Install it in your project. Once done that, all you have to do is to put the following lines of code in your page form:

Friday, August 26, 2011

Remove special characters - PHP


Hi,

I know there are a million ways to remove special characters but this is one of the better solutions which I came across over the internet. Here is the PHP function:

function just_clean($string)
{
// Replace other special chars
$specialCharacters = array(
‘#’ => ”,
‘$’ => ”,
‘%’ => ”,
‘&’ => ”,
‘@’ => ”,
‘.’ => ”,
‘€’ => ”,
‘+’ => ”,
‘=’ => ”,
‘§’ => ”,
‘\\’ => ”,
‘/’ => ”,
);
while (list($character, $replacement) = each($specialCharacters)) {
$string = str_replace($character, '-' . $replacement . '-', $string);
}
$string = strtr($string,
"ÀÁÂÃÄÅ? áâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",
"AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn"
);
// Remove all remaining other unknown characters
$string = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $string);
$string = preg_replace('/^[\-]+/', '', $string);
$string = preg_replace('/[\-]+$/', '', $string);
$string = preg_replace('/[\-]{2,}/', ' ', $string);
return $string;
}

Best of luck

Thursday, August 11, 2011

Reading disabled HTML fields on page submit


Hi folks,

This probably is not a very big solution, but might be useful for newbies. To prevent users from entering data in any textbox or dropdown, you can either use "readonly" or "disabled". Readonly works fine, apart from the fact that the interface of the fields won't look like they are uneditable. Apart from that if it works for you, then its fine.

For "disabled"  option, not only the entire fields becomes uneditable, but also the interface has the feel that it is disabled. The biggest problem with disabled fields is if the form is submitted, the disabled fields are not submitted.


If you face a scenario where you absolutely have to use disabled fields and yet post the values in form submit, then a quick fix would be

Friday, July 8, 2011

Changing Drupal(6.2) theme on the fly

Hi,

This probably will be among my shortest post. The most commonly used module in Drupal for handling theme's is the ThemeKey module. But if you face a requirement where you have to change the theme of the page on the fly, then this post will be helpful.

To change the theme on the fly, you just need to write two lines of code i.e.

global $custom_theme;
$custom_theme="my_theme_name";

That's it. That is all that you have to do to change the page theme in Drupal.


Explanation: