Tuesday, February 21, 2012

Hide format drop down from body

Drupal is such a nice CMS but some of the additional feature may gives us trouble for non technical users. The very common example is Text format drop down in body field. Most of the user try many ways to hide that details. Use following code to hide drop down from node add/edit form


Using hook_form_alter add following code in form alter.


$form['body']['und'][0]['format']['guidelines']['#access'] = FALSE;
$form['body']['und'][0]['format']['help']['#access'] =FALSE


Please share your thoughts if you have any other quick way to hide.




Wednesday, December 14, 2011

Log in as Another user or Admin User

While working with Drupal based project, many times we needs to check different menus with other users account.  Masquerade module is the best solution to handle such situation.


The Masquerade module is useful to those users who wants to temporarily switch to another user account. It also provide option to switch back to the original account.

We can use this module for Individual users as well as specific to  User Role


Steps to use Masquerade  module in Drupal 7
  1. Download  Masquerade module and place it to sites/all/modules folder.
  2. Install that module from Admin , Modules
  3. Set "Masquerade" block from Admin, Structure, Block.
  4. Set permission. We can configure "Masquerade" module in two ways
    1. User Level: 

      1. Go to Admin,  People 
      2. Edit any user profile. Specify usernames what we needs to switch from edited user account in comma separated.

    2. Role Level

      1. Go to Admin , People, Permission.
      2. Set following permissions to specific role

 After implement above settings when  user login following block will appear in page.


When we specify any other user in textbox and press Go button block appear as follows



I am sure that above information will helps you lot. Thank you very much for reading this blog.
Please share your comments regarding this Article.

Wednesday, November 9, 2011

The page isn't redirecting properly - Drupal Multilanguage Problem

In Drupal, many of us face above type of error during multi-language configuration with global redirect module.
We can resolve this error by two ways
1. Disabled Global redirect
2. By Applying Patch in global redirect
(http://drupal.org/files/issues/globalredirect_4.patch)

Once to update any one of technique in your error solve...

Reference: http://drupal.org/node/1082362

Monday, July 25, 2011

General error: Can't create/write to file

This error is very commonly appear when we are working with huge MySQL Database with inno DB storage engine.

To resolve this error we needs to update following variable in my.ini file.
(my.ini file is available in mysql folder)

Variable Default Required
innodb_buffer_pool_size 15M 500M

After update above variable restart Mysql server your issue has been resolved. To get more detail also refer following link

InnoDB Startup Options and System Variables

This technique will work for all version of MySQL

Tuesday, July 12, 2011

Maximum file size, 7087104, exceeded.

This is very common problem we face while generating huge Excel file using PEAR, Php-Excel, php excel writer class . I spent many hours to find out solution and finally found something very useful.

There is some limitation comes with excel file generation.

DescriptionLimit
Maximum number of chars in a string32767
Maximum number of columns256
Maximum number of rows65536
Maximum chars in a sheet name31
Maximum chars in a header/footer254

There are two ways to resolve this issue.
(1) Generate Excel file as per below code.



For huge file use HTML to excel conversion, It works many times for me and it works fine in huge file too.

<?php
$strOutput="<table width="100%" border="1" cellspacing="0" cellpadding="0"><tr>
<td>Column1</td>
<td>Column2</td>
</tr>
<tr>
<td>Value of Column1 </td>
<td>Value of Column2 </td>
</tr>
</table>";

$file = 'myxlsfile.xls';
//export start
header("Content-type: application/vnd.ms-excel; charset=UTF-8");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=" . $file);
echo $strOutput;
?>


Note: Generated file using this method may show some warning when we open in excel.


2) Install OLE::Storage_Lite module 

Thanks for reading my post

Wednesday, April 6, 2011

SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

This is very critical error found  in MySQL. This error originate when you are dealt with huge records. There are various unanswered forum you will found when you Google that problem. The reason behind this crash is packet size. By default, MySQL configuration max_allowed_packet is set it to 16M. This settings may introduce this exception in your website..

Solution:
To resolve that problem you needs to increase max_allowed_packet variable in MySQL. Add following line in my.ini
max_allowed_packet=100M 

Save the file and restart MySQL service. Now onward you will never get that kind exception in your open source / website.

Tuesday, March 29, 2011

PHP Easter Eggs

,We all like something exciting in day to day life. Enjoy following Easter eggs of PHP. It might be well known for some one but those who not aware, E n  j o y !!!
Add following argument in any php sites and get some funny face of php.

For example, if you  want to check in http://www.example.com and apply like
http://www.example.com/?=PHPE9568F36-D428-11d2-A769-00AA001ACF42 
  1. ?=PHPE9568F36-D428-11d2-A769-00AA001ACF42
    This one is the most interesting, and displays an "easter egg" image of either a rabbit in a house (Sterling Hughes' rabbit, named Carmella), a brown dog in the grass, a black Scottish Terrier dog, a sloppy child hand-drawn, crayon-colored php logo, a guy with breadsticks (looks like pencils or french fries) sticking out of his mouth like a walrus, or a PHP elephant logo. The original dog (Nadia) was Stig Bakken's (Stig is one of the PHP developers); the newer dog is Zeev Suraski's dog (the link goes to his blog entry about the dog, called Scotch or Scottie, that died August 30, 2005); and the guy is Thies Arntzen (the logo image was taken from a picture from the PHP Developers' Meeting that the PHP Group held in January 2000). The six images are shown below. The black dog, colored logo, and rabbit pictures are 10 pixels shorter than the other three images.

    Below are the images for various PHP versions:

    PHP CODER GUY WITH BREADSTICKS (Thies C. Arntzen):
    PHP Version 4.0.0 - 4.2.3



    BROWN DOG IN GRASS (Stig's dog, Nadia):
    PHP Version 4.3.0 - 4.3.10



    BLACK SCOTTISH TERRIER (Zeev's dog, Scotch):
    PHP Versions 4.3.11 - 4.4.6; and 5.0.4 - 5.1.2




    BUNNY (Sterling's rabbit, Carmella):
    PHP Version 5.0.0 - 5.0.3



    COLORED PHP LOGO:
    PHP Version 5.1.3 - 5.2.13



    ELEPHANT PHP LOGO:
    PHP Version 5.3.0 - current

  2. ?=PHPE9568F36-D428-11d2-A769-00AA001ACF42
    This is used by the phpinfo function to display the PHP logo, but works on other PHP pages.

  3. ?=PHPE9568F35-D428-11d2-A769-00AA001ACF42
    This is used by the phpinfo() function to display the Zend logo, but also works on other PHP-parsed pages.

  4. ?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000     
    It will open php credit screen with all developer names.


    If you also knowing any more Easter eggs of php or any other technologies , post your valuable comments.

Share it