Skip to main content

Posts

Showing posts from March, 2016

How to Import large CSV file in Drupal with Batch API , Beginners Guide Part I

Recently i have worked on a project which has lots of (in lakhs) data, I have a CSV file which we need to import in database, suppose the CSV have arround 2 lacks data, so when i try to import it then ststem consums too much time and gives the timeout error and failed to upload, to resole these type of issue the Batch API comes in My mind, Why use batch API, Batch API makes a queue of operations and performs each operations one by one, so system did not give the timeout issue, and batch API also shows the status of uploading and remaning data, Here i am assuming you have basic knowledge of drupal module development, Step -1 : create a module within your drupal application, Lets assume module name is dharmend, Now i am going to create a menu , so i have added hook_menu in module file <?php /* implement hook_menu to create a new menu, * */ function dharmend_menu(){ $items['csvImporter'] = array( 'title' => t('Upload Data Fro...

How to span column of custom table in Drupal

If you want to span the column of custom drupal table like below image, Follow the below code to make the header of the table , <?php $header = array('S.N','District', array('data' => '<div class ="house">Household </div><br><span>Rural</span> <p>Urban</p>','colspan' => 2), array('data' => '<div class ="house">Members</div> <br><span>Rural</span> <p>Urban</p>','colspan' => 2), 'Duplicate/Failed Registration', array('data' => '<div class ="house">Pending De duplication </div><br><span>Rural</span> <p>Urban</p>','colspan' => 2), 'Non Un-organised Workers', 'SSID Generated', 'No. of Card Personlised', ); $rows[] = arra...

alter edit form and attach the fields on edit form

if(arg(2)=='edit'){                                                      $prev_node = node_load(arg(1));                            $form['#node'] = $prev_node;                        } now you can get all the form field values on node edit form function create_agency_user_node_update($node){ }