Tag: hire drupal developer

Guidelines for Updating Node Fields Without node_save() In Drupal

Guidelines for Updating Node Fields Without node_save() In Drupal

Customization is nowadays common on Drupal site. Here you may need to save node programmatically at any time. For saving node programmatically we use node_save() hook which will save the whole node though we want to update only one field.

Drupal function field_attach_update() will replace node_save() in some way. It will update only that field which you want to update.

Benefits of field_attach_update()

  1. Reduces load time.
  2. Not update CCK fields.
  3. Easy to use.

Below is the code to use field_attach_update() hook.

// $arr_nids is array of node id that you want to update
$arr_nodes = node_load_multiple($arr_nids);
foreach ($arr_nodes as $key => $node) {
$node->field_fieldname1[LANGUAGE_NONE][0]['value'] = 'field1 value';
$node->field_fieldname2[LANGUAGE_NONE][0]['value'] = 'field2 value';
$node->field_fieldname3[LANGUAGE_NONE][0]['value'] = 'field3 value';

field_attach_update('node', $node);

entity_get_controller(‘node’)->resetCache(array($node->nid)) is used to clear cache for the entity.

For example:

Values before using field_attach_update():

Guidelines for Updating Node Fields Without node_save() In Drupal

Update Fields using field_attach_update():

$nid = '29';
$node = node_load($nid);
$node->field_fname[LANGUAGE_NONE][0]['value'] = 'Johnny1';
$node->field_lname[LANGUAGE_NONE][0]['value'] = 'Harper1';
$node->field_address[LANGUAGE_NONE][0]['value'] = '405, Silicon Tower, Above Freezland Restaurant, Law Garden, Off C.G. road, Ahmedabad, Gujarat - 380009 India.';

field_attach_update('node', $node);

Values after using field_attach_update():

Guidelines for Updating Node Fields Without node_save() In Drupal

Hope this helped you to get most out of the system. Need more assistance for Drupal Development Services then get in touch with us. Feel free to share your reviews and pick the best answer for your requirements. #WeDrupalEveryday


Introduction to Paragraphs Drupal 8

Precious Tips For Paragraphs In Drupal 8 Web Services
Paragraphs is a contributed module which allows creation, administration, and display of customization content components.

In other words, Paragraphs gives you cleaner data structures so you can give more editing power to your end-users.

This module replaces drupal’s standard body field with paragraph types. This allows any type of content to be added on

the page including but not limited to HTML, images, videos etc. All these can be added by users. Users can add as many

paragraphs as they like all the while keeping them all responsive. Developers can reuse paragraphs and layouts.

Paragraphs are basic Drupal entities. This allows site builder control over fields used in paragraphs and their display.

This also makes content saved in paragraphs compatible with Search API, views, and services.

Below is the step by step instructions to work with Paragraphs module:

1 – Download and enable the module
Paragraphs module follows standard process to download and enable.  Module depends on entity reference revision.

You can download and enable this module via drush as well.

2 – Add paragraph types
Paragraphs do not come with any predefined paragraph types. Developers can add as many paragraph types they want by going to admin > structure > paragraphs

To add a paragraph, click on “Add paragraph”. Add fields

Add fields that you want in this paragraph. Go to manage form display and manage display to adjust field display.

3 – Add paragraph field in the content type


Allow this field to have multiple values. Select which paragraphs you want available in this field on field settings and save.

4 – Add content

Add content. In paragraph field, you get a list of all the paragraphs you have created and are available for this field.

Add as many paragraphs as you need.

You can change the order as well.

5 – Theme your paragraphs

Paragraphs can be themed separately. You can use the same template everywhere this paragraph is used.

The file name needs to



Paragraph provides various advantages to all users of the site. Site owners get content that is responsive and works on all platforms.

Content authors can choose on the fly between predefined paragraph types. They get more structured content creation process.

Developers have full control over fields to include and paragraphs and how they should look.

Stay tuned for more on paragraphs!

Hope this helped you to get most out of the system. Feel free to share your reviews or need assistance for

Drupal Website Migration then gets in touch with us. Pick the best answer for your requirements.

Everything You Need To Know About Drupal Mail System

Drupal Mail System

This blog is all about Drupal Mail system. Email sending in Drupal is entirely straightforward. Essentially you just need to manage two stages to send an email to somebody:

In Drupal to sends an email we need to take care of two things:

  • Declare all the required properties (subject, body, headers, etc) under hook_mail().
  • Call drupal_mail() with the argument for actually sending the email.

However, in the situation like greater and complex site, the above strides won’t be sufficient. In any case, Drupal gives us the Flexibility to redo email sending process, before that it’s important to know how stuff functions in the background first, with the help of Drupal you can easily generate custom pdf using the print module. In this blog, I’ll demonstrate to you how you can redo and extend the Drupal mail framework to satisfy your necessities.

The Email Sending Process

While sending an email drupal_mail() function uses system class for sending an email. Each mail framework needs to actualize MailSystemInterface class to define its own mail sending conduct.

MailsystemInterface class utilizes two strategies:

  • format()
  • mail()

The Mail System Module

Mail related settings can be set through Configuration > System > Mail System.

The mail system variable contains two things:

  • default-system => DefaultMailSystem
  • mailsystem_theme => current.

These key-value pairs are the settings you can adjust under the “Mail System Settings” fieldset.


The default-system email key describes which mail system class will be used by default for all outgoing emails.

If you don’t modify the site-wide mail system class then this one will be used by drupal_mail() by default.

The mailsystem_theme defines which theme will be used to render emails. Let’s say you are using Mime Mail which

uses a specific template file for it’s emails. The Mail System module checks every theme registry entry for a specific

“mail theme” key/property and if it exists in a particular entry then the specified mailsystem_theme value will be used

to search for more specific template files when the theme registry entry related theme hook will be called.

New Class

If you have two or more different mail system classes available in your system provided by different modules.

If you want to use any custom mail class which would use format() method of one mail system class and mail()

method from another class, so here you can use New Class which allows combining two different mail system classes.

New Setting

The Mail System module permits you to effortlessly add new email keys to the mail_system variable by choosing a

module and a particular email key from its hook_mail() execution.


Afterward added new email key to the mail_system variable you will ready to choose mail system class for it.

You will have the capacity to see it under all inclusive default MailSystemInterface class settings.

At the point when drupal_mail is called with your demo_custom _mail email key, then the in a roundabout way utilized

drupal_mail_system() function checks if this email_key exists in mail_system variable. It finds the related key then the

related mail system class will be utilized rather than default class.

Hope this helped you to get most out of the system. Feel free to share your reviews and need assistance regarding

Drupal Development Services. #WeDrupalEveryday

Pick the best answer for your requirements.

Tips To Upgrade Commerce Coupon Module In Drupal

Commerce Coupon Module

Commerce coupon module adds Commerce coupon facility to Drupal commerce.

Commerce coupon 7.x-2.x is recommended version. This version depends on Commerce Discount.

Commerce coupon 7.x-2.x has many architectural improvements and new features which include integration with commerce discount, multiple discounts per coupon, integration with inline conditions.

There are no fixed amount coupons or percentage coupons with this version. Instead, we use discounts and use them with coupons.

Upgrading from Commerce coupon 7.x-1.x to Commerce coupon 7.x-2.x is not directly supported. It is two step process.

As per module page on drupal.org, “Commerce Coupon 7.x-2.x-beta2 has an upgrade path from 1.x to 2.x. It works for upgrading relatively simple coupon 1.x sites; mileage may vary if you have a lot of custom coupon functionality though.”

So in order to upgrade to latest commerce coupon, we first need to upgrade to beta2 and then upgrade to latest version.

Below are the steps to upgrade normal commerce coupon setup without any additional customization.

  • First things first, take a backup.
  • Upgrade to Commerce coupon 7.x-2.x-beta3 following standard upgrade process. You will need to add commerce discounts and inline conditions modules installed before upgrading commerce coupon.
  • Once updates are run, you will see your old coupons converted into new coupon and discount systems. Discounts are created for previous fixed and percentage coupons.
  • Upgrade to latest commerce coupon version following standard upgrade process.
  • Make sure to give permission to required user roles to “Redeem coupon”.

This process assumes that there is no custom coupon functionality is added and no additional modules are used along-w

ith commerce coupon. The Success of upgrade process largely depends on how coupon module is used and customization is done on it.

Below are the steps to upgrade commerce coupon with Commerce Coupon by product reference module installed.

  • Take a backup.
  • Delete product reference fields from coupons.
  • Disable Commerce Coupon by product reference module.
  • Upgrade commerce coupon as outlined in steps 2,3 and 4 in upgrade normal commerce coupon.
  • Edit required discounts and add products.

This makes sure that this discount applies to specific products only.

  • Give appropriate user roles permission to “Redeem coupon”.

Since inline conditions are also installed, you can create coupons while creating discounts.

You can also consider adding Commerce discount Extra module which provides various common discount condition And offers types.

Need more assistance regarding Drupal Commerce Module Development Contact us now and Feel free to share your views/feedback for any further queries.

Guide To Customize Google Map Style And Custom Zoom Bar


Google map theming and configuration with custom zoom controls, please follow the below details:

Styling google map allows us to change standard google map style and customize maps visual display like road, water, park and etc.

To make changes in standard google map style, we can use json array as per below:

var styledMapType = new google.maps.StyledMapType([
  { elementType: 'geometry', stylers: [{color: '#EBE5E2'}]},
  { elementType: 'labels.text.fill', stylers: [{color: '#520000'}]},
  { elementType: 'labels.text.stroke', stylers: [{color: '#F5E8DA'}]},
    featureType: 'administrative',
    elementType: 'geometry.stroke',
    stylers: [{color: '#C9A193'}]
    featureType: 'administrative.land_parcel',
    elementType: 'geometry.stroke',
    stylers: [{color: '#DCD6B2'}]
    featureType: 'administrative.land_parcel',
    elementType: 'labels.text.fill',
    stylers: [{color: '#AEA5A0'}]
    featureType: 'landscape.natural',
    elementType: 'geometry',
    stylers: [{color: '#DFDFBB'}]
    featureType: 'poi',
    elementType: 'geometry',
    stylers: [{color: '#DFC47F'}]
    featureType: 'poi',
    elementType: 'labels.text.fill',
    stylers: [{color: '#93746E'}]
    featureType: 'poi.park',
    elementType: 'geometry.fill',
    stylers: [{color: '#9DB04A'}]
    featureType: 'poi.park',
    elementType: 'labels.text.fill',
    stylers: [{color: '#197515'}]
    featureType: 'road',
    elementType: 'geometry',
    stylers: [{color: '#F5E4BF'}]
    featureType: 'road.arterial',
    elementType: 'geometry',
    stylers: [{color: '#FDFBF3'}]
    featureType: 'road.highway',
    elementType: 'geometry',
    stylers: [{color: '#F8C452'}]
    featureType: 'road.highway',
    elementType: 'geometry.stroke',
    stylers: [{color: '#E9BF79'}]
    featureType: 'road.highway.controlled_access',
    elementType: 'geometry',
    stylers: [{color: '#E97741'}]
    featureType: 'road.highway.controlled_access',
    elementType: 'geometry.stroke',
    stylers: [{color: '#DBA37F'}]
    featureType: 'road.local',
    elementType: 'labels.text.fill',
    stylers: [{color: '#80544F'}]
    featureType: 'transit.line',
    elementType: 'geometry',
    stylers: [{color: '#DFCD95'}]
    featureType: 'transit.line',
    elementType: 'labels.text.fill',
    stylers: [{color: '#8F726D'}]
    featureType: 'transit.line',
    elementType: 'labels.text.stroke',
    stylers: [{color: '#EBD9B0'}]
    featureType: 'transit.station',
    elementType: 'geometry',
    stylers: [{color: '#DFD2A9'}]
    featureType: 'water',
    elementType: 'geometry.fill',
    stylers: [{color: '#BAD3C2'}]
    featureType: 'water',
    elementType: 'labels.text.fill',
    stylers: [{color: '#8E9985'}]

Below is the example of google style:

Before style applied

After style applying:

Google map provides ease level of customization.

We can make changes as per our need easily. I have provided an example to configure zoom, scroll, street view and etc options to change default google map.

// Create a map object, and include the MapTypeId to add
// to the map type control.
var map = new google.maps.Map(document.getElementById('gmap'), {
  center: {lat: 23.028349, lng: 72.559097},
  zoom: 11,
  mapTypeControlOptions: {
    mapTypeIds: ['roadmap', 'satellite', 'hybrid', 'terrain', 'styled_map'],
  scrollwheel: true,
  mapTypeControl: true,
  mapTypeControlOptions: {
      style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
      position: google.maps.ControlPosition.LEFT_TOP
  zoomControl: false,
  // zoomControlOptions: {
  //     style: google.maps.ZoomControlStyle.LARGE,
  //     position: google.maps.ControlPosition.LEFT_TOP
  // },
  scaleControl: true,
  streetViewControl: true,
  streetViewControlOptions: {
      position: google.maps.ControlPosition.LEFT_TOP
  fullscreenControl: false

To Add Custom zoom bar:

To add custom zoom bar on the map we can add custom element and use this element we can handle zoom controls.

I have added example code to add custom zoom controls.

// To customize google zoom bar to slider and search controlls
var centerControlDiv = document.createElement('div');
centerControlDiv.setAttribute("class", "gm-custom-controlls");
centerControlDiv.index = 1;

// Add custom zoom controlls
var centerControl = new ZoomControl(centerControlDiv, map, map.minZoom, map.maxZoom, map.zoom);

// map custom controlls to map
// Zoom controlls
function ZoomControl(controlDiv, map, min, max, currentZoom) {

  var parentDiv = document.createElement('div');
  parentDiv.setAttribute("class", "gm-zoom-slider");

  var controlUI = document.createElement('input');
  controlUI.type = 'range';
  controlUI.value = currentZoom;
  controlUI.min = min;
  controlUI.max = max;
  controlUI.style.width = "400px";

  // Add zoom controlls
  var incControlls = document.createElement('div');
  incControlls.id = 'gm-zoom-inc';
  incControlls.innerHTML = '+';

  var decControlls = document.createElement('div');
  decControlls.id = 'gm-zoom-dec';
  decControlls.innerHTML = '-';



  // Click event listner for side-bar
  controlUI.addEventListener('click', function() {

  // Click event listner for inc button
  incControlls.addEventListener('click', function() {
    map.setZoom(parseFloat(controlUI.value) + 1 );

  // Click event listner for dec button
  decControlls.addEventListener('click', function() {
    map.setZoom(parseFloat(controlUI.value) - 1 );

  // Set slider value on zoom change 
  google.maps.event.addListener(map, 'zoom_changed', function(){
    controlUI.value = map.getZoom();

Zoom bar will be displayed as per below screenshot:

Read more regarding Drupal Development Service

How To Show Facets On Non-Search Page As Normal Widget Instead Of List

Show facets on non-search page

Facets allow users to search the site based on selected criteria. Using Facet API module we can add facets on site. For each field that is indexed, we can have facets. These facets can be configured and displayed on search pages. We have various configuration options available for this.

Many times we need to show these facets on pages that are not Search pages. Facet API module does provide this functionality. You need to create a view display of type “Facet blocks”. Below are the steps to do so.

1 – Create a view of search index and a display of type “Facets Block”. You can make this display in the same view as the search page.

2 – Configure “Facet field” and “Search page path”. Search page path is the path of the search page.

The block is then available to be assigned to the region in blocks page.

However, there are several limitations to this:

  1. The facet links will always be styled as a list, no rewrite or format selection is possible.
  2. It is also not possible to use the normal Facet API widgets for these facets. This is because re-using the Facet API components from outside of the Facet API cannot be easily achieved.

In many cases, Professional Web Development need to show facets on the non-search pages as normal facets instead of the list. To achieve this, follow steps below:

  1. Create a facet block as mentioned above.
  2. Show this block on the non-search page as usual.
  3. Make sure that facets blocks are displaying on non-search page as well. Also, make sure that facet block is showing above views facets blocks i.e weight of facets block is higher than the views facets block.
  4. Edit the facet block and set “Display for searches of facets” to “All search page”.

Doing this will make both the blocks visible on the non-search page. You can hide the block showing list using CSS. This solution works for Search API Database Search and Search API Solr Search.

The final result is something like this:

Read more Blogs https://goo.gl/jhRmqR