Share files b/w multi-site environment

Submitted by Sysop on Sun, 11/22/2015 - 18:08

Below are the steps for sharing the files directory between different instances:

Create Target Directory:

sudo mkdir /home/drupal/files

Go to default Drupal sites/default directory or specific site directory path in multisite

cd /var/www/html/sites/<site-one>/

Create symbolic link:

ln -s <target-link> <sourch-link>

ln -s  /home/drupal/files files

Now you can access all the files uploaded via Drupal admin interface can be viewed in /home/drupal/files.

Create jQuery UI Tabs

Submitted by Sysop on Sat, 10/29/2016 - 23:03

steps to Add jQuery UI Tabs with Dynamic Content:

1> Create .libraries.yml file


    js/wedlock_vender_detail.js: {}
    - core/jquery.ui.tabs

2> Create custom javascript file where you can call the tabs() function

in wedlock_vender_detail.js file


3> Add the theme in controller:

Create Menu Links

Submitted by Sysop on Sat, 12/03/2016 - 23:33

#Create menu in configuration form
d8_training.node_menu: # New tab name required
  route_name: d8_training.node_list # Redirect route name
  title: 'List Node'
  description: 'Helper functions, pages, and blocks to assist Drupal developers. The devel blocks can be managed via the block administration page.'
  parent: system.admin_config_development # Appearence in specific settings section

Show more/Less using JS

Submitted by Sysop on Sat, 03/18/2017 - 23:11

Add Show more text using jquery

 * @file
 * Contains the definition of the behaviour js BlackWeight.

(function ($, Drupal, drupalSettings) {
  "use strict";
   * Attaches the JS test behavior to to weight div.
  Drupal.behaviors.BlackWeight = {
    attach: function (context, settings) {
    var showChar = 400;
    var content = jQuery('<wrapper-class-id>').html();

Google Map in Bootstrap Modal

Submitted by Sysop on Sun, 11/22/2015 - 18:10

Sometimes you will get the issues on Map loading inside BS modal. use the below javascript to load the map on full screen BS modal.(User Drupal Behaviours on ajax pages)

<script type="text/javascript">


   $("#ModalMap").on("", function () {

       google.maps.event.trigger(map, "resize");




Create Settings Form [D8]

Submitted by Sysop on Sat, 10/29/2016 - 23:03

Steps to Create configuration Form:

1> Create <module-name>.routing.yml file & add the below entries

  path: 'admin/config/user-interface/jscrollpane'
    _form: '\Drupal\jscrollpane\Form\JscrollPaneSettingsForm'
    _title: 'jscrollpane Settings'
    _permission: 'access administration pages'
    _admin_route: TRUE

2> Create JscrollPaneSettingsForm.php inside src/Form & add the below lines of code

Create Tabbed Menu

Submitted by Sysop on Sat, 12/03/2016 - 23:34
#It is task file it means create Tabbed menu.
<module-name>.tab1:  #New tab name required
  title: Tab 1
  route_name: <module-name>.node_list
  base_route: <module-name>.node_list  # Base route name  

<module-name>.tab2:  #New tab name required
  title: Tab 2
  route_name: <module-name>.node_list
  base_route: <module-name>.node_list


Views Query Alter

Submitted by Sysop on Mon, 06/26/2017 - 00:04
function <module-name>_views_query_alter(Drupal\views\ViewExecutable $view, Drupal\views\Plugin\views\query\Sql $query)
    if ($view->id() == '<view_machine_name>' && $view->getDisplay()->display['id'] == '<views-block-or-page-id>') {
        // Add Condition here
       foreach ($query->where as &$condition_group) {
         foreach ($condition_group['conditions'] as &$condition) {
            if ($condition['field'] == '<your-field>') {
              $condition = array(
                'field' => '<field-name>', // column name prefixes with table name
                'value' => $value  // Op

Get/Set Configuration Value in D8

Submitted by Sysop on Sat, 10/29/2016 - 23:05

Variable Get/Set is now part of Drupal 8 Configuration Service:

Get Value: 

  $config = \Drupal::config('jscrollpane.settings');
  $elements = $config->get('jsp_selectors');

Set Value:

$config = \Drupal::service('config.factory')->getEditable('jscrollpane.settings'); // Set and save new message value. $config->set('jsp_selectors', '.field--name-body')->save(); // Set the value of jsp_selectors

Click here to know about the settings form