Posts

Showing posts from January, 2015

Git reference - submodules

GIT Submodules: To initially set up the submodules: > pwd <main repository> > git submodule init > git submodule update Note: "git submodule update" tell that "hello submodules!! I have commit x as index for you. Please checkout to commit x" > cd <submodule dir> > git checkout master (or) what branch you want > git pull > cd <main repository> > git status > git add <sumodule dir> >  git commit -m "update HEADLINK" short and sweet for init and update: mainrepositry > git submodule update --init --recursive To fetch the latest commit from submodules: > cd <submodule dir> > git checkout <branch> > git pull > cd <main repository> > git commit -m "pulling down latest changes from submodules" short and sweet:   mainrepository > git submodule foreach git pull origin master if the submodules contain other submodules use: mainrepos...

Adding Javascript to Page / Block / Form

1. Adding to JS to homepage ===================== In your template.php add this. function yourtheme_preprocess_page(&$vars) {   if(drupal_is_front_page()) {     drupal_add_js(drupal_get_path('theme', 'yourtheme') . '/js/your-front-script.js');   } }  

How to write a basic Javascript behaviour in Drupal

 A Drupal behavior is a JavaScript object created under Drupal.behaviors object. ( function ( $ ) {   Drupal. behaviors . MYMODULE = { attach : function ( context , settings ) {       // Your Javascript code goes here     }   } ; } ( jQuery ) ) ; Our behavior must contain an 'attach' method, and can also optionally contain a 'detach' method. As you can imagine, 'attach' is called when the behavior is activated, while 'detach' is called when it is de-activated. In most cases, you don't have to implement the 'detach' method, unless you have some cleanup to do in JavaScript (which is rare). The two arguments to the behavior are - context and settings. Context is the DOM object to which the behavior is attached. This could be the form, the form element or often the 'document' object. Typically, you would apply your JavaScript behavior to the 'context' object or its children. Settings can be special JavaScript...