AJAX in Drupal 7

All the Functions for use with Drupal's Ajax framework are situated at /includes/ajax.in

Drupal's Ajax framework is used to dynamically update parts of a page's HTML based on data from the server.

Upon a specified event, such as a button click, a callback function is triggered which performs server-side logic and may return updated markup, which is then replaced on-the-fly with no page refresh necessary.

LDAP Configuration Guide for Drupal 7

Before you can get the LDAP module for Drupal up and functioning, you have to have certain prerequisites already installed and setup on the server.

Drupal 8 Notes

 

Deprecated Calls :

  • watchdog

Instead use

\Drupal::logger('devel')->notice($message); // to log notice

\Drupal::logger('devel')->error($message); // to log error

  • checkPlain

Will be removed from Drupal 9 onwards so suggested not to use in Drupal 8 as well.

Rely on Twig's auto-escaping feature, or use the #plain_text key when constructing
a render array that contains plain text in order to use the renderer's auto-escaping feature.

Some Helpful Links

Basics of Drupal Behaviours

  1. https://benmarshall.me/drupal-behaviors/

Drupal-8 Architecture Explained Nicely

  1. https://cipix.nl/understanding-drupal-8-part-1-general-structure-framework

Drupal Contributors Helpful Tool (Works on Chrome and Safari)

Create Patch for Drupal

Obtain or update a copy of the project

1. Clone the project to obtain a copy of it that you can work with locally. You only need to do this once per project.

git clone --branch [branchname] http://git.drupal.org/project/[project_name].git

2. If you have already cloned, pull the latest changes down to ensure you're working on the latest code.

git checkout [branchname]
[branchname] might be 7.x-2.x for example. Refer : https://drupal.org/node/1054616

Coder - Drupal 8 Module

In order to use Coder module, you would need to Install Coder Sniffer on your machine.  

A detailed steps can be found at  https://www.drupal.org/node/1419988 for Installing Coder Sniffer.   Please follow the steps and you will have it ready to use.

A detailed information about Command Line Usage can be found at https://www.drupal.org/node/1587138

Commands For checking Coding Standards in Drupal 8

Function to Read xls(x) file

  define( 'ABSPATH', true );
  include 'inc/simplexlsx.class.php';
  require_once 'inc/excel_reader2.php';

  $file = $form_state['storage']['file'];
  $file->status = FILE_STATUS_PERMANENT;
  $filepath = drupal_realpath($form_state['storage']['file']->uri);

  ################### mapping of excel readers ###################
    $ext = pathinfo($filepath, PATHINFO_EXTENSION);
  ################################################################

  $output = array();
  //extension logic starts here
  $xlsx_rw = NULL;

Drupal Cron

To write a cron you need to implement hook_cron() in your module. Then, drupal will automatically execute these tasks during the default cron handling.

Note that, using drupal_set_message() function in a hook_cron() implementation makes no sense because there is no user to read these messages. As an alternative, you could log messages with watchdog().

In Drupal 7 you can enable cron via the Administration > Configuration > System > Cron (admin/config/system/cron)

Simplenews Drupal 7 Module

Simplenews Change Un-subscribe URL to Shorten bitly URL

Completely Un-Install Java from Ubuntu

I know, most of times (or should I say always ?) you feel need of installing JAVA from your Ubuntu Machine.  But how about, I installed Java and for some reasons, I don't want it on my machine anymore ?  
Well, here are few direct steps to achieve so.

  • Remove all the Java related packages (Sun, Oracle, OpenJDK, IcedTea plugins, GIJ):

dpkg-query -W -f='${binary:Package}\n' | grep -E -e '^(ia32-)?(sun|oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e '^java-common' | xargs sudo apt-get -y remove

Pages

Subscribe to RSS - sandipte's blog