Posts

Showing posts from January, 2012

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 &qu

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 regions[ ] code l