Posts

Drupal - Custom Login Redirect to current page

To redirect an html login link to back to the current page, (You were on), we need to use $_SERVER['HTTP_REFERER'] with hook_form alter.. For example if you are using a link like... Login any where in the site... function custom_login_redirect_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'user_login') { $form['#submit'][] = 'goback';// go back will be called on submit } $uri = request_uri(); if (($uri == "/user/login") && (!isset($_SESSION['last_page']))) { $_SESSION['last_page'] = $_SERVER['HTTP_REFERER']; } } go back is the function that will be added to submit array to be called after login form is submitted.. Here we are keeping the URL of the last page in "$_SERVER['HTTP_REFERER']" and storing it to some session with name "last_page" When submit is hit, it calls the function in '$form['#submit'][]' i-e ...

Linux - SVN Updating, Commiting file

Goto directory you want to update the file of... cd path/tot/direcoty Best is to get status for the current diroctory from svn server first.. svn status it will list you if there is any update made in the directory to any file if you find any update, you may need to impliment that to your machine first $ svn update A newdir/toggle.c A newdir/disclose.c A newdir/launch.c D newdir/README Updated to revision 32. For aabriviation... A Added D Deleted U Updated C Conflict G Merged if you find a conflict you may find following.. $ svn update Conflict discovered in 'template.php'. Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options: p C template.php Updated to revision 4880. Summary of conflicts: Text conflicts: 1 There is one text conflict.. you can open it in netbeans to see diff. Next you can update svn server for the file you made changes on.. svn comm...

Using jQuery in Drupal 7

This is a practical example – how to use a jQuery code in Druapl 7. We want to use jQuery script code written in hello.js for Druapl 7. We are using bartik theme. Step 1 . Go to your theme folder. Step 2 . Create a folder “js” if it does not exist. (You do not need this step, if you are going to add hello.js file in your main folder of the theme.) Step 3 .  Create  hello.js file under js folder: ex. (C:\xampplite\htdocs\drupal\themes\bartik\js\hello.js) Syntax: }); Note: We are using jQuery (see above in red color) insted of $ sign, in  the beginning of (document).ready as $ sign didn’t work for Druapl 7 in our case. jQuery(document).ready(function($){ $(“p”).click(function(){ $(this).hide(); }); }); Save above code and clear all caches (admin/config/development/performance). Step 4. Put the following single line code in (C:\xampplite\htdocs\drupal\themes\bartik\bartik.info) .info file (You can place this code after the stylesheets[ ] and before the reg...

help with hook_views_query_alter

Hope this must be helpfull

Maximum execution time of 60 seconds exceeded in common.inc - Drupal + Linux

When you are working on Drupal in your local installation some times you get :Fatal error: Maximum execution time of 30/60 seconds exceeded on your browser. I also got that issue and what I did, I added this code block in my settings.php. 1) open your settings.php (sites / all / default/settings.php) 2) add this code for PHP settings: line number between 147 - 168 ini_set('max_execution_time', 0);

Find all the large files on linux server - Linux

To list the files larger than 20MB use the following command in your terminal find / -name "*.gz" -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' The output will be something like this.... /home/fileName.sql.gz: 160M /var/www/fileName.tar.gz: 82M /var/www/Directory/Path/FileName.tar.gz: 82M ... .. . This will find all the gz files. To find the files of all the type, use "*" only. find / -name "*" -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

Ignore or skip some tables while dumping database

To ignore some tables while backingup database use the following.. mysqldump -u dave -ppassword -h localhost --ignore-table=my_db_name.my_table_name my_db_name > dump.sql