• [Drupal-8] How to handle multiple submission buttons in Drupal 8 form?

    July 21, 2016 - 06:24

    I had a requirement to handle multiple buttons in a custom form in Drupal 8. In Drupal 7 we can add multiple submissions using the button definition ['#submit'] => array('my_submit_function'). In drupal 8, same process is possible with slight changes as, ['#submit'] => array('::newSubmissionHandler') in button definition. Also we can get the form values to the custom submit handler as same as default handler. Just see the sample code below for more explanation. Note that the form should be saved in src/Form/MyForm.php.

  • How to install Drupal coding standard checker for command line?

    July 15, 2016 - 11:21

    Coder is a Drupal module to check for coding standard issues in custom modules and themes. It can check any files for coding standard issues according to Drupal specifications. This method uses latest composer and drush to install latest coder. Feel free to skip the following to corresponding parts you need.

    • Install composer

      Check if composer is installed,

      which composer

      If this is empty, proceed with below command. Else skip.

  • How to implement facebook login using FB OAuth in Drupal7?

    May 09, 2016 - 07:48

    In one of my Drupal 7 projects, I had to implement "Login with Facebook" in the site. So I used fboauth module with fboauth_profile2. First I  created a Facebook app. To create a Facebook app, use the following steps in your Facebook profile.

  • [SOLVED] How to include third party libraries in Drupal 8 for custom modules?

    May 09, 2016 - 07:42

    In Drupal 8, third party libraries are downloaded and managed via composer. In each Drupal project there must be only one vendor folder. Composer Manager allows a single vendor/directory shared across all modules which prevent code duplication and version mismatches. This is done by merging the requirements of all modules found, into the consolidated composer.json file. In a custom module, set the dependency for composer manager module in .info file.

  • How to import bulk data in Drupal7?

    May 09, 2016 - 07:40

    I had a requirement to import bulk data to database. Drupal module feeds helps you with this.

    Either you can add url of the data to be imported or upload the file which has bulk data. If want to add url to import data from some other source, use feed importer. The steps to create a feed importer are here.

    If you want to import as a file, use the following steps:

  • How to get path alias and arguments in Drupal 8?

    May 09, 2016 - 07:31

    In Drupal 7, the function drupal_get_path_alias is used to get the path alias from internal path and arg function is used to get arguments from url. But both these functions are deprecated in Drupal 8.

    Drupal 8 uses service container to access various services such as sending an email, accessing a database etc. This ensures that a decoupled nature of the system is respected. We will use the services of current path and path alias to get the result.