Saturday, July 8, 2017

Install drupal console using composer

To install Drupal Console using composer for Drupal 8, use below command from command prompt


composer require drupal/console:~1.0 \
--prefer-dist \
--optimize-autoloader
 
 
 
 

Friday, June 20, 2014

Improve Performance in PHP based website

Some of the basics but essential for performance tuning to any PHP based website

  1. Reduce no of http requests in page.
  2. Index queries which takes too much time. Find expensive queries by activate MySQL slow query log. We can also easily identify which query not use index by specify additional parameter in my.conf reference.
  3. Use PHP function instead of MySQL function. i.e. CURDATE() function gives current date in MySQL use PHP Date function instead of that.
  4. Cache (very basic but it is worth to mention! ). i.e. APC, Memcache
  5. Browser cache is another way when we have less dynamic content.
  6. Minify JS and CSS to reduce document size. Document size mean total size of your HTML page.
If we take care above points we can get good performance for sure.

Wednesday, February 22, 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.

Thursday, November 10, 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

Tuesday, July 26, 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
There was an error in this gadget