Posts

Showing posts from 2015

Continuous Integration with Bamboo - reference

Plan => Build => Deployment Plan    Associate a repository, Write a trigger  SVN: Dev server: Points to 'develop' branch As soon as developer commit the code in 'develop' branch it is automatically deployed in Dev server. svn switch . (or) svn up svn up -> has to be run by a cron in few seconds interval svn switch ? <TODO> Test server: Points to a <tag> A <branch> is created from Dev branch at certain point when the stories are ready for testing. A <tag> is created from <branch> and deployed in Test server svn switch <tag> Testing happens in Test server When bugs are found, they are fixed in <branch>.  <tag+1> is created from <branch> when it is ready for deployment in Test server The cycle continues from steps 3 to 7 UAT server: Points to a <tag> When a QA certified <tag> is available from Test server it is deployed in UAT svn switch <tag...

Display Suite Situations in Drupal

1. Scenerio: The title needs to be printed on image field as overlay. The title field is printed in page.tpl.php and you dont get $title variable in node.tpl.php Solution: In display suite create a code field and put the [node|title] token in that field. In the manage display of fields place the code field wherever you want. 2. Scenerio: There is a Content Type and there is a field xx and field yy. xx is a textarea field and yy is a date/time field. Based on value on yy some different text has to be printed on yy field. Solution: In display suite create a code field and put the [custom|xx] token in that field. In the manage display of fields place the code field wherever you want. Write the logic in token creation code.

Browser plugins to select any element on the page

These plugins will highlight the elements on the page and provide the selector for that. This is very useful where we don't need to refer the JQUERY documentation. This will speed up the development. Jquery unique selector Selector assistant Selector gadget

How to get internet connected to my CentOS in VM

dhclient -v

Multilingual in Drupal7

Locale => To translate strings in t(), provides language switcher blocks, import/export strings, edit strings, manage languages Translate => Provides way to translate nodes. for every node a language copy is created. Entity translation: Added in D8 core. Only one node is maintained for all languages. Fields can be translated into different languages. Reference: https://www.lullabot.com/articles/localized-and-multilingual-content-in-drupal-7#/

Find out which modules call cron

echo theme('item_list', module_implements('cron')); (or) in module.inc put this  foreach (module_implements($hook) as $module) {     $function = $module .'_'. $hook;     if ($hook=='cron'){         echo "$module  <br />";      }

Drupal security reference

1. Always use check_plain(), check_markup(), filter_xss() while you process input data. 2. For Drupal set message use placeholders (or) sanitize using one of check_plain(), check_markup & filter_xss() placeholder example: $output = 'coming from somewhere'; drupal_set_message(t('this is @output', array('@output' => $output))); sanitize example: $output = 'coming from somewhere'; drupal_set_message(check_plain(t('this is '. $output));

SimpleTest reference

While running Simpletest, it only creates core tables and the tables created by modules which you enable in setup method.

Drupal Entity reference

Entity Type ======== Node, User, File, Taxonomy Bundles ===== Article Page 1. You need to create a Entity Controller to do CRUD operation with database table 2. To create a simple custom entity you need following functions hook_entity_info() hook_entity_property_info() An interface which extends DrupalEntityControllerInterface  A Controller class which extends DrupalDefaultEntityController and  implements above Interface 3. Entity API provide some easy functions to interact with entity in code like entity_save, entity_create, entity_delete, etc. 4. Look at the following function in Entity.module. We can save an entity by writing a 'save callback' or writing Controller. Not sure what method_exists($entity, 'save') expects function entity_save($entity_type, $entity) {   $info = entity_get_info($entity_type);   if (method_exists($entity, 'save')) {     return $entity->save();   }   elseif (isset($info['save ca...

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...