Oct 15 2018
Oct 15

A Drupal event is one such destination that I long to visit, each year. Plus, this one happening in Germany was a special one. Yes, you got it right, I’m talking about the Drupal Europe that took place last month at the Darmstadt, Germany. And to answer what apparently made this one a special Drupal event for me is that it was a community-driven event, the scale of which matches with that of a DrupalCon. Such enthusiasm and such efforts! Applauds and appreciation to the entire Drupal community of Europe and worldwide for having shown such a withstanding support for Drupal and making #DrupalEU such a massively successful event.

 

We Volunteer! 
Yes, did volunteer and contribute in order to do our share in supporting this massive and enthusiastic community-driven event called the Drupal Europe 2018. Isn’t that what is expected out of a hardcore Drupaler like us, who’s been a working aggressively for the community ever since 2012. We’re involved with the website part of the event and came up with a few bug fixes too. We intended to contribute on a way larger scale, but alas the time constraint and the work commitment. While not trying to redeem ourselves, but isn’t working on a Drupal project for a client is too a form of contribution done for the community?! Did just heard a yes from you!

Drupal Email

The Enthusiastic Event & Visually-Stunning Venue! 
Drupal Europe is said to be the biggest European Drupal event, by far. The event was organized at the Darmstadtium - a beautiful structure of modern architecture with a mark of history living in it. Yes, amidst the exceptionally designed modern Darmstadtium stands an old wall from history. 

Drupal Europe, 2018

The five-day event at this exceptional structure had almost 1000 Drupalers from across the world. The event was divided into three major areas; one, where the booths were set up by different Drupal sponsors, two, where the sessions were being conducted by the Drupal experts, and third, where the Bird Of Feather(BOF) sessions were organized.

 

Entire CMS Community Under One Roof! 
Drupal Europe spoke for and promoted Drupal extensively and dedicatedly. But that does also not mean shunning away from the entire open source community. Hence, a concept of ‘Open Web Lounge’ was also implemented at  Drupal Europe, like other open source community events. Here people from the entire open source community come under one roof to brainstorm and discuss relevant topics of the community. It’s an informal gathering where a bunch of like-minded people tries and contribute to the community with their solutions & suggestions. This is one of the healthiest things happening across all the community-based events.

 

Sessions, Booths & BOFs
A Drupal event is always about a host of things to do and programs to attend. So much so that one always misses out on several such things. So did I! But thankfully I also got to attend a series of sessions, which I completed cherished. Like the one on the ‘Autosave and concurrent editing in Drupal 8’ by Hristo Chonov,  ‘Drupal Diversity & Inclusion’ by Tara King & Elli Ludwigson, ‘The Way We Work’ by Kevin Bridges and Elli Ludwigson, and many more! Apart from this I also attended a couple of BOFs and walked through different stalls and connected with different people from the Drupal community.

Drupal Europe, 2018

A Perfectly Creative Prenote!
Yes, this time I’ll prefer sharing details about the prenote prior to that of the Driesnote. The prenote topped the list of fun events at Drupal Europe, 2018. Jeffrey A. McGuire, along with Campbell Vertesi, Adam Juran and others came up with the most creative and innovative Prenote ever. And the part that stole my heart was the recreation of ‘Imagine’ with a touch of Drupal in it. Just Phenomenal!

Drupal Europe, 2018

The Driesnote
One of the most awaited parts of any Drupal event has to be the #Driesnote, by the founder of Drupal - Dries Buytaert. He started with a goal to build a Drupal that people love, and shared the roadmap he has structured to reach this goal. He went ahead sharing the updates regarding the initiatives taken so far with the community members present at Drupal Europe. He also spoke about the marriage of React UI and Drupal, in order to improve the overall administration experience of the site. Like always, Driesnote was an insightful session to attend. Here’s the link to the entire Driesnote, for those who missed out on it.

 

The #DrupalCEO Dinner!
Last but certainly not the least! It was a night to remember with the senior level executives of the companies actively working for the Drupal community and the founder of Drupal himself - Dries Buytaert. And we feel privileged to be a part of this exclusive and prestigious dinner night. It’s a new initiative, initially started by a handful of CEOs of Drupal companies, which later got widely popular. Though an informal event, the DrupalCEO dinner is an event that brings out the best of suggestions and surveys from the leading Drupal-ers around the world.

The #DrupalCEO Dinner, Drupal Europe, 2018

This one was my first Drupal community-driven event and believe me, it was a phenomenal experience in itself. The enthusiasm and efforts of the community were soaring aloud of the strength of the Drupal community at large, which apparently translated into such a progressive vibe at the event!

Sep 06 2018
Sep 06

Drupal, the most favoured open source platform, took a huge leap with the launch of its latest version - Drupal 8. Today, it is not a mere open source platform; rather an enterprise level web content management that is pledged to provide an ambitious digital experience. Despite of being the best on the technical front, Drupal 8 is facing issues in terms of visibility on a larger level. Today, the digital world is not just reigned by the technical people. A whole lot of non-technical and new decision makers has arrived, which affects and influences the market. This is where Drupal 8 was lagging behind and was missed from the eyes of these key influencers. And hence, arose the need of promoting it globally. Hence, ‘Promote Drupal Initiative’ came into the picture.

DrupalCon, Nashville, 2018 was when the founder of Drupal talked about the ‘Promote Drupal Initiative’ extensively. Highly suggested by the technical experts, Drupal 8 now needed to touch the base of non-technical influencers of the market and influence them. A hell lot of marketing, promotion, and upgradations was needed to be done in order to penetrate the radar of non-technical influencers of today. And Dries shared his plan to promote Drupal, divided into 4 different phases:

  1. Strategy and Planning

  2. Drupal.org Improvements

  3. Public Relations

  4. Events & Advertising

Drupal 8 has seen an impressive rise of 51% increase in its adaption over past 1 year. The technical experts were aware of the strength of Drupal 8, but the absence of the 3rd ‘P’ of marketing i.e. ‘Promotion’ made the non-technical decision makers unaware of what Drupal 8 is capable of doing. Dries in his keynote at the DrupalCon, Nashville mentioned that ‘Drupal Promote Initiative’ aimed at gathering the support of $100,000. The enthusiastic supporters of Drupal had already contributed, as a result of which the initiative had already yielded $54,000. Addweb too has contributed to this growth-oriented initiative with a very humble contribution, alongside other eminent contributors from across the globe.

This voluntary-based initiative has gained a huge momentum so far, which is enough to prove the robustness and competence level of Drupal 8. As a member of the most ambitious digital experience that Drupal 8 is, each member of the community is inclined towards fostering the ‘Promote Drupal Initiative’ and Drupal at large. Destined to meet the goal, the ‘Promote Drupal Initiative’ is going to elevate the market of Drupal 8 and eventually raising the bar of open source community a notch higher!

Aug 31 2018
Aug 31

‘Think of the technologically best content-management framework, think of Drupal!’

The statement stands true and its adaptation by the big-shots of every industry possible acts as a strong confirmation for it. Drupal has anyway been the most favored platform by experts of the community. And the release of Drupal 8 has just been accelerated this demand. The rich and robust open-source community of Drupal has always been a reason to choose Drupal over any other framework. But now with the length of futuristic and competent upgradations that Drupal 8 has come with, the popularity has taken an unbelievable rise and extended reach. In fact, now, even the non-technical decision makers around the world have been citing the strength of Drupal 8.

At AddWeb, we have been Drupal-ing every day - ever since our inception. So from the experience that we’ve gathered in all these years, let us give you some epoch-making reasons to upgrade your site to Drupal 8. Have a look at them!

1) Multilingual Feature

The admin panel of Drupal 8 offers extensive multilingual features, along with multiple built-in features for translation. It enables you to have a page-wise filtration for choosing different languages. The Drupal community is wealthy enough to provide you with automatic translation updates. Businesses/website having a multilingual audience is no more a hassle with Drupal 8.

2) Magic done with HTML 5

Simplifying HTML5 coding is the next best thing done by Drupal 8. This brings in more clarity and direct access to different input fields like date, phone, email, et al. Even the compatibility and functionality with the other related devices like smartphones and tablets is increased. The theme based templates for writing HTML5 coding is like a cherry on the cake since it helps the budding web designers in doing their job.

3) Template Engine - ‘Twig’

Twig is a PHP based theme template engine that now comes as an inbuilt with Drupal 8. This brings in a lot of benefits since Twig is much more flexible, secure and fast-paced as compared to its other counterparts. And despite Twig templates being high on security, it is also the simplest since it is written in syntax.

4) Built-in Web Services

Drupal 8 has a robust open source community at its back and now it also comes with output content in several formats viz. JSON, XML, et al. The RESTful web API is a service that helps in exposing entities and other resources. The modified version of Drupal also lets you use the Hypertext Application Language.

5) Mobile Friendly

Designed in a mobile-first approach, Drupal 8 is a thoroughly mobile-friendly platform. Drupal 8 themes are designed in such a manner that it can easily be adapted by devices of different sizes. It also comes with a ‘Back to Website’ Button so that one can also have the experience of a website’s desktop view on their mobile device itself.

6) New Configuration Management

Drupal 8 also comes with a built-in configuration system that smoothens the task of carrying different elements like the type of content, fields, and views, etc. Every single change is minutely recorded by this very version of Drupal, which immensely helps in bettering the control and responsibility sharing.

7) Authoring with Ease

Powerful authoring tools are introduced to support and enhance Drupal 8. The content editor tools are WYSIWYG Editor and CKEditor, along with some draft creation tools. Elevation with the place editing, that comes with the core module, is done impressively. A simple editing window and you can now do your content editing in the simplest of manner.

8) Built-in Fields  

The recent most and trending field types like entity reference, email, telephone, link, et al, comes included in the core of the Drupal 8. Hence, no further formatting and coding is required for all these new fields.

9) Easy Download

In Drupal 8, almost every entity of the website is cached and required Javascript gets downloaded. The cache memory is stored, when the page is visited for the first time; so that the next that page is visited the process of download need not be repeated and the page can be viewed quickly. All this to make the entire process smooth and easy going.

10) Accessibility Integration

A range of accessibility and support techniques gets a magnificent scope to elevate, which includes WAI-ARIA, Aria Live Announcements, TabManager, et al. All these techniques also enhance the internet supporting applications. Accessibility is one such facet of Drupal 8, which remains untouched and is unparalleled to any of its counterparts.

Today, Drupal 8 is much more than a mere content management system; especially after the plethora of features that this version of Drupal comes with. We’ve shared only a handful of such features that needed your immediate attention. And of course, the official site of Drupal 8, will help you gain specific details about the richness of Drupal 8. But one more thing that you need to know now, is that Drupal 8 is a full-fledged enterprise cloud-based web CMS. Plus, the scope and ease to connect with the 3rd party frameworks like Javascript, boosts the

Are you also planning to upgrade to Drupal 8 and looking for the best of team to do it for you? Well then, hire AddWeb’s expert team of Drupal 8 developers, because only a true Drupal-er can bring justice to your expectations!

Aug 17 2018
Aug 17

‘Coexistence is the key to our survival’, they say about humanity. The same law applies to and therefore is adapted by the technological world too. ‘Decoupled Drupal’ is the outcome of the same law, coming from the field of web architecture. After years of following the traditional web architecture, Drupal came up with something that was not ‘monolithic’ - something that we call as ‘Decoupled Drupal’ today. Let us explore and decode in detail the web architecture that ‘Decoupled Drupal’ is!

Understanding, Decoupled Drupal

Understanding, Decoupled Drupal

Freeing the front-end from the control of the content management system and focusing on the just back-end development. The presentation layer, themes, templates - everything front-end is taken care by the adopted front-end framework. This also implies that Drupal has chosen to do what it does the best - building and bettering the content part. The decoupled Drupal exposes the content to other systems such as native applications, JavaScript application, core REST API, IoT devices, et al, which clearly states the fact that every system can easily consume content from Drupal.
 

Decoupled Drupal, also known as Headless Drupal, in simpler words is about not letting go the core and robustness of Drupal by having the control over all the core content management related responsibilities. And yet opening up the door for the productive change on the part of content appearance. Decouple Drupal is a promise of omnichannel delivery for the marketers and publishers.
 

Pick your approach!

Approach Decouple Drupal

1) Coupled Drupal

This is the most appropriate approach to be adopted for a site that does not demand much rendering and state management from the client’s end. Drupal’s built-in twig templating system is used instead of the huge and heavy JavaScript framework. The help of JQuery can also be taken if needed. Since this approach doesn’t block content marketers by the front-end developers, extra marketing expense could be cut down.

2) Progressively Decoupled Drupal

A website that requires client-side interaction, Progressively Decoupled Drupal is being used. Under this approach the core strength of Drupal - its HTML generation is not eliminated and yet the benefits of the Javascript framework is adapted. The best of both the frameworks raises the quality of interactive experience plus a robust back-end. Usage of JavaScript enables the content marketers to freely gather the experience and benefit from it, without much of the developer’s support.

3) Fully Decoupled Drupal

The entire structure here is separated in terms of the content and the presentation, where the former one is taken care by Drupal and the later one is prominently undertaken by JavaScript frameworks. With both the advantages and disadvantages attached to this approach, it is not a highly recommended one. Independence on the underlying CMS and usage of the richness of JavaScript and its community, is one of the major advantages of the fully decoupled Drupal, while the addition of complexity to the technology stack is one of the major disadvantages.

Why should you be adapting Decoupled Drupal?
 

Adapting Decoupled Drupal

The popularity of the Decoupled Drupal is a reason enough to confirm how beneficial it has proven to be, so far. Let us share some prominent reasons why adopting the decoupled Drupal will prove to be advantageous for you:

1) Intact Security

Security - the key benefit of using Drupal is kept intact since the content management and back-end is taken care of by Drupal itself. The administrative CMS is kept far from the public eye is also something that helps in keeping the security level high.

2) Elevated Team Performance

Drupal CMS development requires more technical expertise as compared to that of some other front-end framework. So, when an expert of Drupal has more time and scope to focus on the segment that he has an expertise upon, the outcome would naturally be of that stature. In addition, the front-end developer will also have the freedom to work on his expertise and hence would be able to give better justice to your website with an overall elevation in the team’s performance.

3) Broader Approach

Drupal has always been broad with its approach, be it any website or organisation. In addition, Drupal now also has the publishing functionality that streamlines the experience for content creation. Under this architecture, it’s easier to push and manage the content to other places. This widens the possibility of the same content being spread and published on multiple channels.

4) Flexibility

Decoupled Drupal enables and accelerates the scope flexibility, whenever the website is in need of some change or upgradation. The independence to work and focus upon one single aspect, the developers and designers are granted the flexibility to dedicate their time to their respective jobs. The elimination of dependency of the back-end developers/tools from the front-end developers/system is what lifts up the scope of flexibility.
 

Already thinking of adapting the highly-trending and powerful architecture - Decoupled Drupal? Well, our Drupal-expert team might help you get a detailed and better understanding of the same. A customized viewpoint of Decoupled Drupal for your website surely makes a huge difference. Let our Drupal developers make that difference for you!

I hope this blog helps you to expand your Decoupled Drupal knowledge …Thanks! If you need more assistance regarding Drupal Development Services, feel free to contact us now.

Aug 09 2018
Aug 09

What is ReactJS?

Created to enhance speed, simplicity, and scalability, ReactJS has been doing wonders ever since its initial release in 2013. It was basically created by Jordan Walke, a software engineer at Facebook. And its first deployment on Facebook’s newsfeed turned out to be so successful that it was later on adopted by Instagram too. Amongst all the open-source platforms used today for front-end web-application development, ReactJS is the library which is reaching heights these days. And there are multiple reasons for such a booming popularity in such a short period of time. Each adding to the enhancement of current front-end UI scenario. No wonder it looks like, ReactJS is here to stay!

What is Drupal?

Drupal is the big name from the open-source community for web content management. Prominent names from journalism leaders like ‘The Economist’ to ‘The Royal Family’ of Britain. The security and scalability of Drupal are so high that it has made it the most trusted platform for web development.

Even after being a not-too-easy-to-use platform that requires technical expertise for building and maintaining it; Drupal has been chosen by the top-notch players from various industries like Harvard University, Tesla Motors, ABS-CBN News, Warner Bros. Records, et al. In addition, the Decoupled Drupal is the concept where Drupal can be used for building a strong back-end and opening up the doors for upscaling the front-end scenario even more by letting it being build with some other framework. And this is one of the best things ever happened to Drupal.
 

The Marriage of ReactJS & Drupal:

Now, ReactJS is gaining immense popularity and the marriage of ReactJS and Drupal has become the talk of the town. In fact Dries Buytaert, the founder of Drupal, has also shared he's planning on Drupal adopting React. Though the news has received mixed opinions from the experts of the open-source community, it’s definitely something to be given an ear to.

ReactJS and Drupal are supposedly called the marriage made in heaven. ReactJS is one of the most evolved front-end frameworks from the house of JavaScript. But like every other JavaScript framework, this one too needs and a service-based back-end for storing the data and working on the business logic. Drupal being the strongest platform with built-in RESTful services; it serves as an apt companion for this amazing front-end framework that ReactJS is.

The uprising need for using a modern framework with a robust back-end platform is also a reason behind the buzz created around the combination of ReactJS and Drupal. In fact, Dries has quoted in his blog that JavaScript wasn’t his first choice. Rather he considered Angular and Ember over JavaScript. But citing the ever-evolving market of JavaScript, he realized that the combination of Drupal and ReactJS was what the modern web needed the most.
 

The community behind ReactJS is also one of the major reasons for taking it into high consideration over other good frameworks. Also, whether it is about ornamenting the current page and few of its elements or it’s about creating a full-fledged single page app (SPA), this very combination is the sure-shot success. Lullabot shares some insightful information about the same, click here to know more.

Some hardcore Drupal Monolithic-ians have also publically discarded the official union of ReactJS and Drupal. But since the world is ever changing and the possibilities, endless; the acceptance of the same can be foreseen. Of course, it is a matter of conflict and controversy. But then, only time can tell how things turn and what reigns the open-source community!

I hope this blog helps you to expand your ReactJS and Drupal knowledge …Thanks! If you need more assistance regarding Drupal Development Services, feel free to contact us now.

Jun 25 2018
Jun 25

Drupal meetups are all about gathering up the Drupal-ers around the local community and helping the community grow at large. AddWeb Solution Pvt. Ltd. recently took up this initiative and organised a Drupal Meetup in Ahmedabad - India’s first heritage city declared by UNESCO.

A little about AddWeb and its association with Drupal

AddWeb is an outsourcing agency, based out of Ahmedabad with its clientele spread across the globe. Being an active member and contributor of Drupal community, AddWeb has been doing its bit for Drupal community from time to time. The recent one, being this Drupal Meetup held on 9th June 2018 at AddWeb premises.

AddWeb Drupal Meetup

About of the Meetup

The meetup was organised with the primary goal of elevating the local Drupal community and the secondary goal of promoting new ideas to strengthen Drupal in our area. The meetup was designed and divided under 3 different sessions, each session meant to bring us closer to our goals. Below is the brief hint on what each of these sessions was about:

1) Decoupled Drupal

An open discussion about the most talked thing coming from the house of Drupal. In the meetup, several aspects of Decoupled Drupal were discussed.

Drupal Meetup- Decoupled Drupal

2) Component-Driven Front-end Development

Drupal is bringing in some major changes and innovation to its existing format. Component driven front-end development is one such innovation that needs your attention.

Drupal Meetup: Component-Driven Front-end Development

3) Decoupled React Editorial Experiences

A remotely setup session that was supposed to be taken by Ruben Teijeiro from 1XInternet, did not happen due to last minute urgency of the speaker.

 

Though the third session couldn’t be conducted, AddWeb has promised to incorporate it in the next meetup that we organise. All in all 50+ Drupal-ers joined us in the meetup and shared their insights on both the conducted sessions. Overwhelmed by their active participation and enthusiasm for the event, we’re motivated to plan more such Drupal Meetups in future. Let’s unite and keep on making efforts to build the Drupal scenario is our respective geographical setups. Because Drupal-ing is fun!


 

Event Sponsor: AddWeb Solution Pvt. Ltd.

Venue Sponsor: AddWeb Solution Pvt. Ltd.

Event Organizer: Ashish Jain

May 17 2018
May 17

“When the bond is strong, relationships lasts long!” said no one in specific because some facts are too true to be cited in words. But why are we talking about this in here and not Drupal? Well, because it is about Drupal; to be precise, our relationship with Drupal!


We realised this quite recently while on the way to our 10th Drupal event, ever since our inception in the year 2012. In these 5 years, we’ve attended 9 Drupal events, sponsored 5 of them and volunteered in 8 of them. Then how could we miss this one in Nashville?! And here we’re, back from the DrupalCon, Nashville 2018, with a bagful of memories and experiences to share. So, if you weren’t there, read on to discover all that was there!

 

Quick Overview of the Event Timeline

The five-day event, that DrupalCon was, had been traditionally divided into three major sections - Summits, Sessions and Contribution. Business Summit, Sessions & Contribution Day.
 

  • The opening day had summits and training sessions, along with the opening reception.
  • Day two had programming summits and sessions planned, along with the much-anticipated session of Dries’ Keynote. 
  • The third and fourth day was when multiple sessions were held followed by special events in the evening and trivia nights. 
  • The closing day of the event was all about Drupal contributions, just as it is at any other Drupal event.

But what made this particular event stand out for me, from the previous ones, were the booths of both - Joomla and WordPress. Now that’s how we see the competitors coming together for the sake of saving open source community from their counterparts. 

Major Takeaway from the Event

1) Business Summit:
As a regular attendee of Drupal events, we knew the significance of the paid business summits held on the first day of the event. So, we had priorly registered for the same. After attending them, we realised that the core of these summits lied in two major things. One, that Drupal alone was not enough and second, the need to promote that Drupal is not merely a CMS platform for building websites but a wide and highly ‘Ambitious Digital Experience’ in itself. 

2) Dries Keynote:
Amidst the commencement of several sessions, the second day at DrupalCon, Nashville 2018 most of us waited for that one crucial session; #Driesnote - the keynote by Dries Buytaert, founder of Drupal. It revolved around three prime agendas - Drupal 8 update, Growing adoption of Drupal and Fostering the Drupal Community. He confirmed the fact that how Drupal is capable of doing everything digital and called it to be the most ‘Ambitious Digital Experience’ of our time. Plus, the decoupled Drupal had opened up the opportunity to get the best of Drupal and collate it with any other user-friendly front-end framework. 

He also declared to take Drupal 8 in the right directions it has become necessary to take up marketing techniques for promotion. And hence, the Drupal Association has launched the ‘Promote Drupal Initiative’ for raising $ 100,000 of which they’ve already bagged $ 54,000 so far. 

Many such significant stuff was shared in the Dries Keynote and to watch its entire recording click here.
 

3) Sessions:
The third and fourth day consisted of multiple sessions running parallelly. We attended quite a lot of sessions and re-bonded with old Drupal friends over a cup of coffee. ‘Delegating Work: A Zippy Guide to Releasing Your Death Grip on Control’ by Hannah Del Porto from Brick Factory, ‘Debugging Effectively’ by Colin O’Dell from Unleashed Technology and ‘Beyond Websites: Drupal as Data Pipeline for Digital Signage’ by Mike Madison from Acquia - are few of the sessions that we thoroughly enjoyed.

And of course, on both the nights had bumper social events to end the day, along with our fun fellow-Drupalers. Since we met many old friends from Drupal community, we made quite some memories with those fellas! 

DrupalCon, Nashville 2018 had one more day to go to conclude, which was the Contribution Day. But unfortunately, our already planned schedule did not permit us to stay back and be a part of the concluding day. One does feel this loss, especially when they’ve been a contributor in past and know the importance of being a part of such a day. But anyways, the experience that we earned in the previous 4 days was quite enriching. It has opened up a lot of hope and opportunities for people like us, who are hardcore Drupal enthusiasts! 
 

May 11 2018
May 11

The concept of a global village is getting more and more real with the advancement of ‘online’ world. And online shops share a major part in this advancement. But with the elevated need of building an online store, the options offering platforms to build these stores has also elevated.

Here’s where our experience and expertise come in picture. After 500+ man hours spent over building about 10+ Ecommerce websites, we’ve come to a conclusion that Drupal is indeed the best choice for building an Ecommerce website. So, here are the 11 realistic reasons to guide you through while choosing the best platform for building an Ecommerce website for you; which is undoubtedly Drupal Commerce

1. An Array of Inbuilt Features 
Drupal is priorly loaded with all the features that are required for building a website viz., product management system, payment modes, cart management, et al.

2. Time-Saving 
Development time reduces since the time consumed in first developing and then custom integrating two separate systems is eliminated.
 

3. SEO Friendly 
Drupal is SEO friendly and hence, helps your website rank higher in the search engine

4. Negligible Traffic Issues 
Heavy traffic is never an issue with Drupal since it is backed by a wealthy system to support the traffic.
 

5. Social Media Integration 
Social Media platforms like Facebook, Instagram, Twitter, LinkedIn, etc comes priorly integrated with Drupal. 

6. High on Security 
Drupal is high on security grounds and hence, comes up with an inbuilt solution for securing your data/information on the website. 

7. Super Easy Data Management 
Data management becomes easy with Drupal since it is the best content management system. 

8. Feasible for E-Commerce Websites
Easy to built and run a Drupal-based eCommerce website, whether it is a small size enterprise or large business houses. 

9. Inbuilt Plugins for Visitor Analysis  
The inbuilt plugins for visitor reporting and analytics help you to easily evaluate your website without any external support. 

10. Customization
Drupal is flexible enough to make your website a customized one. 

11. Every Single Code is Free!
Drupal firmly believes in maintaining the integrity, the core of Open Source Community, where nothing is chargeable and every single code is for everyone to use. 


And you thought we’re trying to sell it just because ‘We Drupal Everyday’? Well, good that now you’re aware of the selfless efforts we make to solve your tech-related confusions! We at AddWeb are Friends of Drupal Development.

Feb 14 2018
Feb 14

In one of our project, we have to list all post of a content type with search and sort functionality. And the main thing was search form was in the header whereas sort fields were a location in another region.
              
Therefore when we explore search and sort fields from view, both the fields were coming up together.
              
There are two options to overcome this situation:
         

  • Block Clone module

There is one contrib module “Block Clone” is available.
Using this module you can set single block at multiple places.
To solve our above problem we can set expose fields block at two places. and using CSS/jQuery we need to hide/show relative fields as per the block position (like for search block, hide sort fields).
              

  • Search API Sorts

As we already have used Search API module, we go with Search API Sorts contrib plugin.

This module is dependent on Search API module. This module creates a separate block only for sort fields.

  • We need to follow below steps to configure this module:
  • Install and activate this module
  • After activating this module, you can able see link in admin i.e. configuration >> Search and Metadata >> Search API. Select it.
  • You need to create an index first over there.
  • After creating Index, there will be a tab named "SORTS".
  • In that tab, you can able to select fields which you want to make it sortable.

              
By doing this, it will create a separate block for sorting fields & you can place that block where you actually need it.

Hope this helps you well, feel free to add your comments/feedbacks. Need more assistance regarding Custom Drupal Development Get in touch today!

Jan 11 2018
Jan 11

The world is painted in the mood of celebrations. As the end of the year comes closer, the more clearer visuals of the passing year comes in front of our eyes. Believe it or not, all of us a nostalgic bunch of souls wrapped in the fancy dreams and ambitions of the coming year. Even while reading this you’re nodding your head yes with a nostalgic smile on your face and moisty glow in your eyes. Don’t worry, we all are sailing in the same boat. So, instead of keeping it all within we thought to share our 2017 story with our loved ones. Hope, our story will leave you motivated to write your story too and share it with us! 

The outset of 2017

Like every coming year, 2017 too came with a bundle of surprises for us to unfold with time. We kicked off the year with yesteryear’s memories in our hearts and a lot of dreams to be accomplished through the year. We’re more than 4+ years old with 110+ man-years of experience, 25+ teammates, and  500+ - small, medium and large-scale projects. We knew we had a long way to go in order to give justice to the mark 2016 had left us with. And hence, we’re all geared up to plunge into the pool of challenges and surprises that 2017 had in the store for us.
 

Paramount Projects of the Year 

The year had just started and we got lucky with a high-ranking project on board. The client asked us to create a gateway for the Bitcoin for their OctoberCMS based website. It was the first time that we forayed into the field of Cryptocurrency. And our enthusiastic troupe of coders, successfully closed it like a pro! We also expanded our skill-set by exploring and working on a few more tech stacks viz. Lumen, Bitusu, Catalyst, DevOps/docker implementation, et al. Meanwhile, we also got a firm hold over OctoberCMS and of course Drupal 8. 

Bitcoin

AddWeb Turns 5!

We were still engrossed in coding new things, little did we realised that it was about time for some celebration - A birthday celebration! Yes, AddWeb turned 6 during July 2017 and we celebrated the birthday of our little one with lots of fun activities and a scrumptious cake. We’re - “One more year older. One more year wiser.” In fact, by that that we even grew bigger as a team and hence gifted ourselves with a whole new, creative office! 

AddWeb's Birthday

Proud Moments! 

Being a Drupal-er, since our very inception, contributing something huge was sort of a dream for us. And finally, 2017 gifted us with one such opportunity. We finally contributed an Admin Theme to the Drupal community. And if that was not enough of a joy to be felt proud of, Dries Buytaert overwhelmed us by mentioning us in his blog. In that blog, based on the credits earned by the contribution made towards the Drupal community, we got listed at the 27th position in the list of world’s top companies contributing towards Drupal community. Also, by elevating the quality of our contribution we took a huge leap from being amongst the world’s top 100 companies at Drupal marketplace during the start of 2017 to securing a place in the top 20 Drupal companies by the end of the year. Can their be a bigger joy for a hardcore Drupal-er like us?!

Moments

We Code. We Create. We Celebrate! 

By the way, did we tell you? Celebrations are as much as a part of AddWeb as coding is. We like to be in the celebration mood throughout the year. Being the true Indians, we don’t miss even a single opportunity to celebrate. From celebrating the festival of colors - Holi in the office to celebrating the festival of lights - Diwali, we proactively plan and participate in every such event. We go out during Garba nights for swirling and twirling together and also sometimes plan a terrace party to get grooving on the dance floor. We twin by wearing same outfits and sometimes code together with a dress code of checks and polkas. And oh! How can we forget our Udaipur trip! It was one hell of a trip that will remain in memories forever. 

Celebrations

And also, ‘We Care’!

While celebrations kept the mood and mind of our AddWeb family in a happy zone, we introduced a series of physiotherapy sessions to make sure their health also remains very much in that happy zone. They are the asset of AddWeb and hence, caring and doing a bit for their health, make us happy!

We Care

AddWeb on Expedition

Some more memories that we made through the year, were from our trips to the DrupalCamps that we attended worldwide. Like 2016 was all about sponsoring every such event that we attended, 2017 was all about attending the event as a speaker. We spoke about ‘Women in Tech/Drupal’ at both - DrupalCamp Mountain Camp 2017 Switzerland and DrupalCamp Frankfurt 2017. Around the end of the year, we also attended the New England Drupal Camp 2017 and one of biggest and our very first WordCamp - WordCamp US 2017. It was not just memories but also a shedload of learnings that we brought back home with us. 

Aj Trip Aj Trip

Atithi Devo Bhava! 

We weren’t just visiting the faraway lands, but also welcoming our clients from distant places and helping them explore our city and culture. 2017 brought home Rainer & Lutz, our German clients, to our office. And we proclaim, “Atithi Devo Bhava”, treated him with a very humble hospitality and took them on a tour around the city. On the tour, they tasted some local spicy Indian food, visited the city’s must-visits like Gandhi Ashram and ended their tour with some authentic food, again. And it’s needless to say, how much they relished the entire tour! 

Client Visit

We Work the Smart Way!

Every year, such expedition of ours introduces us to a million new things. We explore a few interesting ones from them and then come back home, mould them to fit in our environment and bring them to practice. And 2017’s one such customised creation is ‘Artful Agile Process’. Artful, because we have artistically melded it retain the deliverance of quality and at the same time managing the resource in a very street-smart way. Every single project of 2017 was done under this process and guess what?! It turned out to be one of the most fruitful creations of ours, so far. 

 

In fact, not just how we work but we have also molded the method of how we hire. A smart filtering flow has been formed in order to select only the best ones and that too in the least expected time. And under this newly introduced ‘Smart Hiring Process’ we’ve also made a lot of rejections. All of these, just to keep up on the route of maintaining quality and progressing! 

Agile Hiring

Giving Back to the Community at large! 

We believe in giving back to the community. And hence, have came up with a new in-house concept of ‘AddWeb Academy’. The academy is ready to roll out with the commencement of the new year. It intends to provide the freshers with a thorough professional training of Web Development and coding, which can further help them build their career.
 

Academy

Waiting to Welcome 2018!

Looking back through the year, we realised that we’ve achieved a lot and yet there’s a long way to go! And as the year is about to end with some nostalgic feelings and celebrations, we’re all set to bid it a beautiful goodbye with loads of love and gratitude. We’re all waiting to welcome 2018 with our 50+ member AddWeb family, over 200+ man-years of experience and a shedload of enthusiasm. Here we go to chase bigger dreams with an even bigger team. Happy celebrating 2017 and welcoming 2018!

Year End
Dec 28 2017
Dec 28

“We Drupal Everyday” - this very catchphrase of AddWeb is enough to portray our love and dedication for Drupal. And it is our this love for Drupal that has taken us on the tour of DrupalCamp, across the world. This time our Drupal-destination was NEDCamp, held in Worcester city of the United States of America.

 

Our excitement and enthusiasm being at its peak, brought us to the city a little earlier before the camp commences. Though we’ve been attending, volunteering and sponsoring Drupal Camps ever since 2015, our curiosity and zest remained as high as the first-timers. And like every time, this time too we wanted to attend every single session. But alas! We could only make it up for just a few to them. Amongst which Kelly Albrecht’s session on Agile Design, Jason Pamental’s session on variable fonts and the future of web design, AmyJune Hineline’s session on the simplicity of Git-in, et al were high on our list. And oh! How can we forget Drupal 8!! NEDCamp brought us a galore of opportunities learn about Drupal 8. And then there were BOF (Bird Of Feather) sessions, where we got to sit and discuss our queries and concerns around Drupal with the like-minded Drupal-ers around the world.

 

Every Drupal camp we visit, bring us a new perspective and motivation to contribute even more towards Drupal. And do you know, what part of Drupal Camp brings us the maximum amount of motivation? It’s the social gatherings that they organise like lunch sessions and dinner nights. We look forward to them not just because we get to meet and greet fellow Drupal-ers, but also because it’s here where we get to meet some old friends and make a few new ones! All of us, coming from diverse countries and cities, brings a diverse range of cultural perspective. We get a chance to get exposed to a whole new sociological aspect of different beings, ranging from food, customs, languages, beliefs, et al - all under one single roof. Believe us, this gives us a different high!

 

Of course, it’s needless to say but NEDCamp 2017 was indeed a very fruitful experience, alike every other DrupalCamp that we have been a part of. It would be unfair if we wouldn’t thank all the sponsors, organisers and of course the volunteers - who selflessly contributed their time and energy for the betterment of the community. Thank you guys, you made it happen once again!

 

Many more #DrupalCamps to attend, sponsor and volunteer! Many more contributions to be made towards the most robust open source framework - Drupal!

Nov 13 2017
Nov 13

The hunt for a decent Drupal developer has never been a child’s play. One, because Drupal in itself is a complex tool that requires a high-end expertise and hence Drupal developers are less in number as compared to others. And second, one also has to be technically literate to a certain extent, in order to sense their expertise and hire accordingly. 

 

Well, you need not be scared, if you aren’t that well-versed about the tech-world. Especially, when you have AddWeb Solution to your rescue. We, being a pack of powerful Drupal-ers since 2012 and currently ranked at the 24th position in the marketplace of Drupal Service Provider, you know that you can put faith in our words. And as always, we’re more than happy to guide you through your search of a good Drupal developer.

 

Let us share a few pointers that have to be on your checklist while shortlisting a Drupal developer for yourself.

 

1) Profile on Drupal community:
What better recommendation of a Drupal developer than the one coming from Drupal’s official website itself?! And guess what, Drupal doesn’t bluff! It purely works on the merit basis, where the Drupal developers’ activeness in the community and their contribution is displayed. If one doesn’t have a profile on Drupal Community, you know you’ve to think twice before hiring them! 

 

2) Certification:
“Skills, not degrees, take you far.” True. But when in the ever-changing techno-world, you can’t shun the significance of certificates that these software companies give. So, if you come across a certified Drupal developer by Acquia, you know you’ve found the best champ to hire.

 

3) Work Profile:
Remember, that work speaks for itself! Well, don’t let some fraud deceive you with pretty presentations and flattery words. Ask for their work profile and invest your time and energy over analyzing them. And you’ll soon be a judge yourself, whether to trust the person or not. No wonder why a lot of companies goes all boastful about their clientele. 

 

4) Coding Languages:
“The more the merrier” is the mantra you need to follow while choosing a Drupal Developer with the knowledge of multiple coding languages. Since Drupal is built with the PHP language, it becomes mandatory for a Drupal developer to be well-versed in it. But knowing just PHP is also not enough, he needs to be multilingual when it comes to coding languages; majorly, SQL, MYSQL, JQuery, et al. And of course, not to forget ‘English’. It may not have any technical benefit attached to it, but it will surely enhance your communication with him!

 

5) Activeness on Drupal Community:
Drupal is a high-end open-source content-management framework, which is available free of cost. But the prominent reason behind its growth and flourishment is its community. People from all across the world, gather-up here and share their knowledge and queries here. A Drupal developer’s activeness here in this community also speaks for the wealth of his Drupal-related knowledge.

 

There may not be a guaranteed checklist to help you hire only the best of Drupal developers, but a few tips like these can always prevent you from a disastrous selection. And in case, you’re still stuck in your search; remember, our super-skilled Drupal developer’s team is just a call away! 

 

May you have a happy ride, searching a decent Drupal developer!
 

Aug 08 2017
Aug 08

Paragraphs

Paragraphs are one of the modules that make site builder and end users more powerful. Paragraph module does this by replacing one big WYSIWYG with predefined paragraph types. Paragraph module utilizes entity reference field to reference paragraph types. Paragraphs are basically entities so users get control over fields and theming of the paragraph.

Bootstrap 

Bootstrap is sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development. Bootstrap has become one of the most popular front-end frameworks and open source projects in the world.

A combination of these two is "Bootstrap Paragraph" module.

"The Bootstrap Paragraphs module provides a suite of content and layout Paragraph bundles made with the Bootstrap front-end framework."

Using bootstrap paragraph module, it is very easy to create features like an accordion, modals, tabs, multi column layouts, and many more things. 

The module has multiple dependencies including paragraphs, Entity reference revisions, contact formatter to name a few. The module also needs Bootstrap framework’s js and CSS added in site theme. Installing this module via composer could be beneficial.

Module installation follows a standard process. The module comes with predefined paragraph bundles which can be accessed from /admin/structure/paragraphs_type. These paragraph bundles are divided into 2 main categories: 

Content bundles

  • Simple HTML
  • Image
  • Blank
  • Contact Form
  • Drupal Block
  • View

Layout bundles

  • Accordion
  • Carousel
  • Columns (Even, up to 6)
  • Columns (3 Uneven)
  • Columns (2 Uneven)
  • Modal
  • Tabs

Each paragraph type comes with 2 options: 

Width and background color

Over 50 background colors are already defined. Empty background classes are also available to customize based on your theme. These classes are :

  • .paragraph--color--primary 
  • .paragraph--color--secondary 
  • .paragraph--color--success 
  • .paragraph--color--info 
  • .paragraph--color--warning 
  • .paragraph--color--danger

Predefined width options include following:

  • Tiny - col-4, offset-4
  • Narrow - col-6, offset-3
  • Medium - col-8, offset-2
  • Wide - col-10, offset-1
  • Full - col-12

To use these paragraph bundles, an entity reference field referencing to paragraph needs to be added to a content type. This field can have unlimited value to allow site builders to add as many paragraphs as they want. Once set you can start creating content. With this module, you can place a piece of content in your own structured page.

Additional Features

  • Paragraphs and fields are saved in the database. This means that whatever changes are made in them are also in the database. 
  • Theme CSS gets precedence over module CSS. You can copy template files in theme from a module and overwrite CSS as you desire.
  • The module can be uninstalled without losing paragraphs and CSS. You need to move all templates and CSS to your theme. Remove “attach_library” calls from template files and call CSS from theme’s library.
  • You can use this module to create reusable paragraph bundles via a module.

To summarize, Bootstrap paragraph module is a suite of Paragraph bundles made with the Bootstrap framework. With this module, you can easily position chunks of content (Paragraph bundles) within a structured layout of your own design.

Hope this blog helped you and explore more about Paragraphs also need assistance for Drupal 8 Services then get in touch with us Feel free to share feedbacks.

Jul 12 2017
Jul 12

Customization is nowadays common in 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.

A 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));
}

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);
entity_get_controller('node')->resetCache(array($node->nid));

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

Jul 08 2017
Jul 08

Paragraphs is a contributed module which allows creation, administration, and display of customizable 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

Introduction to Paragraphs Drupal 8

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

Introduction to Paragraphs Drupal 8

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

Add paragraph field in the content type. 

Introduction to Paragraphs Drupal 8

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.

Introduction to Paragraphs Drupal 8

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--machine-name-of-your-paragraph.html.twig”

Summary

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 get in touch with us. Pick the best answer for your requirements.

Jun 21 2017
Jun 21

Don't want long forms on your website? Convert it into multi-step form, as it is more convenient and provides step by step procedure to follow by user. This blog will provide a way to create of multi step form using ajax.
                   
1. Create a menu item using hook_menu()

/**
* Implementation of hook_menu().
*/
function custom_menu() {
$menu['multistep_form'] = array
(
'title' => 'Multistep Form',
'description' => 'To create multistep form',
'page callback' => 'drupal_get_form',
'page arguments' => array('ajax_multistep_form'),
'access callback' => TRUE,
);
return $menu;
}

2. Define a callback function
 
It includes stepwise fields. It contains fieldset for each step with their respective fields. Then It will includes buttons for each step. We have called ajax_multistep_form_ajax_callback function it returns the entire form each time the function is called. Added a wrapper div “ajax_multistep_form'” to update the form using AJAX.

$form['buttons']['next'] = array
(
'#type' => 'submit',
'#value' => t('Next'),
'#ajax' => array
(
'wrapper' => 'ajax_multistep_form',
'callback' => 'ajax_multistep_form_ajax_callback',
),
);

Multistep Form Using Ajax Multistep Form Using Ajax Multistep Form Using Ajax
function ajax_multistep_form($form, &$form_state)
{
 
// If $form_state['step'] is not set then set default to 1
$form_state['step'] = isset($form_state['step']) ? $form_state['step'] : 1;
// Add a wrapper div to update the form using AJAX
$form['#prefix'] = '<div id="ajax_multistep_form">';
$form['#suffix'] = '</div>';
 
switch($form_state['step'])
{
// Step 1
case 1:
$fname_default_value = $lname_default_value = '';
if(isset($form_state['values']['step_1']))
{
$fname_default_value = $form_state['values']['step_1']['fname'];
$lname_default_value = $form_state['values']['step_1']['lname'];
}
elseif(isset($form_state['storage']['step_1']))
{
$fname_default_value = $form_state['storage']['step_1']['fname'];
$lname_default_value = $form_state['storage']['step_1']['lname'];
}
 
$form['step_1'] = array(
'#type' => 'fieldset',
'#title' => t(''),
'#collapsible' => false,
'#collapsed' => false,
);
$form['step_1']['fname'] = array(
'#type'=>'textfield',
'#required' => true,
'#title'=>t('First Name'),
'#default_value' => $fname_default_value,
);
$form['step_1']['lname'] = array(
'#type'=>'textfield',
'#required' => true,
'#title'=>t('Last name'),
'#default_value' => $lname_default_value,
);
break;
// Step 2
case 2:
$phone_default_value = '';
if(isset($form_state['values']['step_2']))
{
$phone_default_value = $form_state['values']['step_2']['phone'];
}
elseif(isset($form_state['storage']['step_2']))
{
$phone_default_value = $form_state['storage']['step_2']['phone'];
}
 
$form['step_2'] = array(
'#type' => 'fieldset',
'#title' => t(''),
'#collapsible' => false,
'#collapsed' => false,
);
$form['step_2']['phone'] = array(
'#type'=>'textfield',
'#required' => true,
'#title'=>t('Phone Number'),
'#default_value' => $phone_default_value,
);
break;
// Step 3
case 3:
$city_default_value = $city_default_value = '';
if(isset($form_state['values']['step_3']))
{
$street_default_value = $form_state['values']['step_3']['street'];
$city_default_value = $form_state['values']['step_3']['city'];
}
elseif(isset($form_state['storage']['step_3']))
{
$street_default_value = $form_state['storage']['step_3']['street'];
$city_default_value = $form_state['storage']['step_3']['city'];
}
 
$form['step_3'] = array(
'#type' => 'fieldset',
'#title' => t(''),
'#collapsible' => false,
'#collapsed' => false,
);
$form['step_3']['street'] = array(
'#type'=>'textfield',
'#required' => true,
'#title'=>t('Street Address'),
'#default_value' => $street_default_value,
);
 
$form['step_3']['city'] = array(
'#type'=>'textfield',
'#required' => true,
'#title'=>t('City'),
'#default_value' => $city_default_value,
);
 
}
 
 
// Form Buttons
$form['buttons'] = array
(
'#type' => 'container',
);
// If we are on step 1, we do not want a back button
if($form_state['step'] !== 1)
{
$form['buttons']['back'] = array
(
'#type' => 'submit',
'#value' => t('Back'),
'#limit_validation_errors' => array(),
'#submit' => array('ajax_multistep_form_back_submit'),
'#ajax' => array
(
'wrapper' => 'ajax_multistep_form',
'callback' => 'ajax_multistep_form_ajax_callback',
),
);
}
 
if($form_state['step'] !== 3)
{
$form['buttons']['next'] = array
(
'#type' => 'submit',
'#value' => t('Next'),
'#ajax' => array
(
'wrapper' => 'ajax_multistep_form',
'callback' => 'ajax_multistep_form_ajax_callback',
),
);
}
else
{
$form['buttons']['submit'] = array
(
'#type' => 'submit',
'#value' => t('Submit'),
'#ajax' => array
(
'wrapper' => 'ajax_multistep_form',
'callback' => 'ajax_multistep_form_ajax_callback',
),
);
}
return $form;
}

3. Add validation for your fields
 
It will add validation for phone number field in step 2. You can add validations for other steps too.

Multistep Form Using Ajax
function ajax_multistep_form_validate($form, &$form_state) {
switch($form_state['step'])
{
case "2":
$contact_phone = $form_state['values']['phone'];
$contact_errror = '"'.$contact_phone .'"' . ' is not a valid North American phone number. Please enter a valid ten-digit phone number with optional extension in this format 123 456 7891.';
if (!preg_match('/([0-9]{3}?\s?[0-9]{3}?\s?[0-9]{4})/', $contact_phone)) {
form_set_error('phone', $contact_errror);
}
break;
}
}

4. Final submit function

function ajax_multistep_form_submit($form, &$form_state) {
 
$step = $form_state['step'];
 
//$form_state['storage']['step_' . $step] = $form_state['step'];
 
if($form_state['step'] == 1) {
$form_state['storage']['step_' . $step]['fname'] = $form_state['values']['fname'];
$form_state['storage']['step_' . $step]['lname'] = $form_state['values']['lname'];
 
}
if($form_state['step'] == 2) {
$form_state['storage']['step_' . $step]['phone'] = $form_state['values']['phone'];
}
 
if(isset($form_state['values']['next']) && $form_state['values']['op'] == $form_state['values']['next'])
{
// Goto next step
$form_state['step']++;
}
 
if(isset($form_state['values']['back']) && $form_state['values']['op'] == $form_state['values']['back'])
{
// Goto next step
$form_state['step']--;
}
// Check if it is last step
elseif(isset($form_state['values']['submit']) && $form_state['values']['op'] == $form_state['values']['submit'])
{
 
$form_state['storage']['step_' . $step]['street'] = $form_state['values']['street'];
$form_state['storage']['step_' . $step]['city'] = $form_state['values']['city'];
 
$items = array($form_state['storage']['step_1']['fname'], $form_state['storage']['step_1']['lname'], $form_state['storage']['step_2']['phone'], $form_state['storage']['step_3']['street'], $form_state['storage']['step_3']['city']);
drupal_set_message(t('You submitted the following values:!values', array('!values' => theme('item_list', array('items' => $items)))));
 
$form_state['step'] = 1;
$form_state['storage'] = array();
}
$form_state['rebuild'] = TRUE;
}

5. Ajax callback function for every buttons in our form

function ajax_multistep_form_ajax_callback($form, &$form_state)
{
return $form;
}

This it just an example, you store all steps value in “$form_state['storage']” and use it.

$step = $form_state['step'];
$form_state['storage']['step_' . $step]['values'] = $form_state['values'];

Hope this helped you to get most out of the system. Feel free to share your reviews or need assistance regarding our CakePHP development services then get in touch with us. #WeDrupalEveryday. Pick the best answer for your requirements.

Jun 13 2017
Jun 13

As a Drupal solution provider, our passion for contributing to Drupal community started from Drupal Camp Brighton 2015, which continues and has brought us today attending Drupal Camp Frankfurt 2017 as well. Frankfurt is one of the world’s leading financial center with historic, ethnic and cultural diversity like the Paulskirche, the Römer, and the “Museumsufer”, captivating skyline, big fair, traditional restaurants and the list is endless.


Drupal Camp Frankfurt 2017 took place at University of Frankfurt, Bockenheim on 22nd and 23rd April 2017, owing to its large campus the sessions and sprints were conducted with utmost ease. Germany Drupal Community was very welcoming and their effort was commendable to promote Drupal in the German market. It was a camp by the community for the community so that beginners can learn and develop an insight into Drupal technology and experience the depth of the community.

Drupal Camp Frankfurt was spread over two days with interesting sessions, sprints, social gathering, and discussions to exchange knowledge and experiences of the community members. We were more excited as we could contribute by conducting a session on “Women in Tech/Drupal” by #dcffm17 speaker Mr. Ashish Jain.

Day 1:
On 22nd April, the day started with a welcome session followed by a keynote by Antje Lorch on “Why you will be contributing to Drupal”, which cleared everyone’s thoughts about giving back to the community as much as they take advantages. This was followed by various sessions, out of which some interesting topics were Media & Drupal – Modules and Workflows for Publishers, deGov - Building a Distribution based on Acquia Lightning and Get the most out of display mode. And the day ended with an open-ended session and at last with an incredible social night at the restaurant and bar Depot 1899, which helped us know each-each other beyond Drupal.

Day 2:
The second day kick started fresh with interesting sessions and various discussions with the community members that even included newbies, who had good knowledge and that created a great atmosphere. After the lunch break, Mr. Ashish Jain presented a session on “Women in Tech/Drupal” in which he highlighted the position women have achieved, global stats about women’s position in the tech world and about the position of women in AddWeb Solution that has lead to change in work environment and increase productivity. All the attendees of the session appreciated our attempt for #genderdiversity.

On the whole, it was a great learning experience and it's always a delight to meet the community members anytime to boost up the Drupal quotient and share personal experiences. The event was memorable and a big thank you to the organizers, sponsors, volunteers and all community members for such a great event.

Feel free to view some cool snapshots from here

AddWeb Solution can’t wait for the next community meeting, so as to contribute even more to the Drupal community and show the love for Drupal!!

May 12 2017
May 12

Display modes are one of the core functionalities of Drupal 8. They are easy to create and provides great flexibility in terms of theming at entity viewing and editing level. Display modes are available for content, comment, contact messages, custom blocks, taxonomy terms, users. They are also available to views adding more power to views.

Display modes are located at Admin -> Structure -> Display modes -> View mode.

Two types of display modes are available: "view modes" and "form modes."  Both these are example of configuration entities.

View modes allows site builder to request a field to be rendered in a certain way. For example, we can have an article that has doctors field has entity reference. On article full mode display, we can request few details of doctor to be displayed. We can create a new display mode (“Doctor details”) to do so. On Doctor’s full view, we can include a brief summary of articles associated with them. 

To create View mode 

Navigate to Admin -> Structure -> Display modes -> View mode

1. Click on “Add view mode” to add new view mode

2.  Created view mode is available on content types. Navigate to manage display of the content type and enable view mode.

Once enabled, this mode can be used on referenced field.

Once view modes are enabled, we can theme it as per requirements. To get template suggestions, you need to turn on debug property from services.yml. 

You can find theme suggestion in inspect element.

Display modes can also be used based on conditions and we can switch mode based on conditions.

function hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
  // For nodes, change the view mode when it is teaser.
  if ($entity->getEntityTypeId() == 'node' && $view_mode == 'teaser') {
    $view_mode = 'my_custom_view_mode';
  }
}

Hope this helped you to understand Display Modes in Drupal 8, Feel free to drop us a line for any Drupal 8 related work/queries/tasks, or Need any assistance regarding Drupal 8 Web design & Development. Always ready to help :) 

Apr 24 2017
Apr 24

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.

Everything You Need To Know About Drupal Mail System

DefaultMailSystem

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.

Everything You Need To Know About Drupal Mail System

                   
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.

Everything You Need To Know About Drupal Mail System

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.

Apr 21 2017
Apr 21

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 with 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 offer types.

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

Apr 10 2017
Apr 10

My Takeaways from the Drupal Mountain Camp Event, 16-19 February 2017, Davos, Switzerland.

~Climb mountains, not so that the world can see you but so you can see the world!~ And I was blessed to get the opportunity in the most beautiful place on earth! Imagine attending a Drupal Event in the scenic Swiss Alps (with temperatures plummeting to as low as minus 11)! The sights were no less than a fairy tale, and the Drupal learning – truly out of this world. No words can describe, no camera can ever capture the beauty of the place (and the learning from the event) - one has to live it, experience it and boy were I lucky! 

The 4-day Drupal Mountain Camp Event was held at Davos – a valley in Eastern Switzerland and surrounded by snow-clad, picturesque mountains. My hotel was located at an altitude, with the very relatively low level of oxygen. The experience was truly exhilarating – almost like Drupal coding while hiking! The venue of the Mountain Camp Event is an International Congress Center, host to many International conferences. The 4-day event, held from 16-19 February 2017 was a perfect combination of coding and (winter) chill, events and entertainment, food and fun. 

The first day began with a warm welcome of a delicious chocolate mountain – the Swiss are known for their chocolates, and the mountain was truly a finger-licking experience. While the days were spent in workshops and sprints – with extraordinary learning, evenings were fun-filled. On the Thursday evening, we got to try our hands at ice skating! Having only seen people skate in movies, it was a great chance for us to feel no less than movie stars! On the next evening, we got to enjoy an incredible sledge ride in the Alps - spinning down the slopes (at what feels like a million kilometers an hour) resulted in a great adrenaline rush. On Saturday night, we got to see a live ice hockey match between Davos and Zurich – thanks to the sponsors. And on Sunday, after a day spent in sprints, we could also ski and snowboard – god was I living a dream?

I was very lucky to have heard some great keynotes (especially on Open Source & API first Drupal), some eye-opening talks and sessions in the Drupal community, in addition to education, research, and Agile process tips for attendees of all levels (technical developers, business owners, and project managers). 

With this event, I experienced my many firsts! My 1st time in Switzerland, my 1st time as a speaker, my 1st sledging adventure, the 1st time I witnessed snowfall, and my 1st Live Hockey match! I was also privileged to attend the Speaker Dinner (don’t forget to catch the pictures on Twitter and Flickr). The social nights were fab – I thoroughly enjoyed the Swiss beer, made some great new friends, and danced to some peppy Indian and Bollywood numbers. 

I thought I was the farthest travelled attendee, all the way from India, while there was Lauri who came from across the world – Australia.  A memory: Signing on the Drupal Love board was fun, and it has been safely stashed by Ursin Cola.

All in all, a marvelous event! I would like to thank the organizers, sponsors, and speakers from the bottom of my heart, and also to those innumerable strangers who helped me find my way in a German speaking country, a place where English is not even an option! 

Apr 06 2017
Apr 06

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:

Guide to customize google map style and custom zoom bar

After style applying:

Guide to customize google map style and custom zoom bar

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
map.controls[google.maps.ControlPosition.BOTTOM].push(centerControlDiv);
// 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 = '-';

  parentDiv.appendChild(decControlls);
  parentDiv.appendChild(controlUI);
  parentDiv.appendChild(incControlls);

  controlDiv.appendChild(parentDiv);

  // Click event listner for side-bar
  controlUI.addEventListener('click', function() {
    map.setZoom(parseFloat(controlUI.value));
  });

  // 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:

Guide to customize google map style and custom zoom bar

Hope this helps you. Feel free to share your feedback and need any assistance regarding Drupal Development Services.

Mar 14 2017
Mar 14

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.

Show facets on non-search page

2 - Configure "Facet field" and "Search page path". Search page path is the path of the search page.

Show facets on non-search page

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

Show facets on non-search 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:

Show facets on non-search page
Feb 28 2017
Feb 28

Nowhere to Elite group member, We had seen Blog about Let’s foster Contribution - Now, let's get the background history of how we reached to the common Goal..?

“Today, more people use Open Source, but fewer people contribute back than ever before. And everybody else assumes that others are doing” - Nadia Eghbal

This was not an overnight decision, it took a couple of days to study and understand the concept. And finally we got an idea of it and we jump into Drupal.org Community to contribute and get involved in many ways.

February 2015, we started our Journey as the novice over Drupal.org Community. 

Drupal.org Journey

I remember the look and feel of Company page was different where on the right side of the page - Team members were displayed. We started like tortoise “Slow and Steady”.

Started creating profiles of each Drupal team member.
Pushing Team member’s hard towards contribution. And over the time it became habit and part of our process.

We started with normal doubt solving postings and maintaining track records. 

Drupal.org Journey

Days passed and we found a post where we can apply the patch to it. Vivek Chauhan - Our Themer put his leg forward to apply for the patch. 

Drupal.org Journey

And guess what..!! It was not uploaded successfully, our patch failed. :( Disappointing moment for team who put in their efforts. But team didn’t stop their efforts and kept trying with different patches and resolving issues and we got our first success with patch submitted by Snehal Brahmbhatt - Our Senior Core/Drupal Developer. 

The Team gained confidence and were now aware of the process Drupal.org followed for:

Submitting patch with correct the patch name.
Commit properly through Git.
Applying “Needs Review” status.
End User OR Tester tests the patch and puts “RTBC” status.
And then owner commits the patch to latest release.

Drupal.org Journey

An Year passed and team increased from 15 to 30 people. Gradually, competition took place between team members of contributing more and more..

Force became competition and then a habit. AddWebers works of a common goal - foster contribution culture. 

Contributions in Gujarati Translations: We are among the Top 3 contributors.

Drupal.org Journey

Moving one step forward - We got our very first Module co-maintainership with Media Recorder. And journey continued with targeting more..

Drupal.org Journey

And then team was unstoppable with getting credits and appreciations #kudos over #slack.

Drupal.org Journey Drupal.org Journey

And AddWeb's Journey continues..!!!

Feb 27 2017
Feb 27

Please follow the below steps to Generate custom pdf:

1: First you need to install and enable print module.
2: Download dompdf from https://github.com/dompdf/dompdf on github.
3: Put dompdf library in "/sites/all/modules/print/lib/dompdf".
4: Add below code at the starting of the custom module file.

    use Dompdf\Dompdf;

5: Create your html structure that you want to print in pdf and set your html structure to $result like below example.


    $result = '<table>
      <tr>
        <td>
          fitst row first column
        </td>
        <td>
          fitst row second column
        </td>
      </tr>
    </table>';
  

6: Add condition for print module and not empty result. 

  if (module_exists('print') && !empty($result))

7: If condition is TRUE then under condition add library path like that 

$file_path_include = drupal_get_path('module', 'print') .'/lib/dompdf/autoload.inc.php';
    require_once $file_path_include;

8: Create object for Dompdf.

    $dompdf = new Dompdf();

9: Add your html structure in object's load_html method.

    $dompdf->load_html($result);

10: Add below line to generate output.

 $dompdf->render();
    $pdfoutput = $dompdf->output();

11: Set file name and file path that you want to store. Keep the name dynamic if there are multiple pdfs by appending date-time.

$filename = 'demo.pdf';
    $filepath = 'sites/default/files/pdf/demo.pdf';

12: Write file using below code. This will generate pdf at "sites/default/files/pdf/demo.pdf".

    $fp = fopen($filepath, "w+");
    fwrite($fp, $pdfoutput);
    fclose($fp);

Here is the full code:

    use Dompdf\Dompdf;

    $result = '<table>
      <tr>
        <td>
          fitst row first column
        </td>
        <td>
          fitst row second column
        </td>
      </tr>
    </table>';

    if (module_exists('print') && !empty($result)) {
      $dompdf = new Dompdf();
      $dompdf->load_html($result);
      $dompdf->render();
      $pdfoutput = $dompdf->output();
      $filename = 'demo.pdf';
      $filepath = 'sites/default/files/pdf/demo.pdf';
      $fp = fopen($filepath, "w+");
      fwrite($fp, $pdfoutput);
      fclose($fp);
    }

Hope this demo helps you.Need more assistance regarding Drupal Web Design Services...!

Feb 01 2017
Feb 01

How to Use External Invite for User in Drupal 7? 

Imagine a scenario where you need to invite some of site users to accept some role on the site. You do not want to go and edit every such users and assign them said role. You also want leave the choice with users if they want to new role on site or not.

Enters User External Invite module.

This module allows users with proper permission to invite other users. Users have specified time before the invite expires. Inviting users also have option to cancel invite and resent invites.

Below is step to step guide to install and use this module.

1 - Download the module and install as usual.

Download the module from here: http://drupal.org/project/user_external_invite and install as usual.

2 - Configuration

Go to “admin/people/permissions” and set permission for required roles to send invite.

Go to admin/config/people/invite and set configurations as required.

Select which user roles can be invited, default role, expiration times and templates.
You can customise the emails that will be sent on various occasions here as well.

3 - Invite users

To invite users go to admin/people/invite and add address you want to invite. 

You can select role for which invite is being sent. You can also add custom message. This message will be added in email that is being sent to invited users.

4 - Manage Invites

You can manage invites from admin/people/invite/operations.

On this page, you can see list of all invites that are sent and status of each invite. From this page you can either cancel an invite or resent the invite.

The module also implements various checks such as you can not disable module till you have pending invites, making sure that roles are not changed when invites are pending for that role etc.

The module also provides a hook which can be used in case inviting email id is not present in the system.

Hope this article has helped you. Need more assistance regarding drupal development services..!

Jan 30 2017
Jan 30

Recently i had a problem where i need to migrate locations added by “Location” module in Drupal 6 site to Drupal 8 site. Currently “Location” module does not provide Drupal 8 version, so i used “Address” module in Drupal 8, but still i need to get all contents.

To solve this, i have created a custom module in Drupal 8. Steps to update locations:

  1. Create a folder /modules/custom/MODULENAME
  2. Create “MODULENAME.info.yml” file inside MODULENAME folder with following details:

           name: MODULE NAME (This can be anything you want)

           Description: MODULE DESCRIPTION
           Package: Custom

           type: module
           core: 8.x

           dependencies:
           - address:address

           More info on creating modules .info.yml file can be found here.

      3. Now, as i need to migrate data on cron run, i created “MODULENAME.module” file and implemented hook_cron

   <?php
/**
 * @file
 * File to migrate contents
 */

    function MODULENAME_cron() {
        Write code here…..
}

We need to connect to Drupal 6 database for exporting its content. Add the following code in /sites/default/settings.php along with the default database connection:

  $databases['external']['default'] = array (
  'database' => ‘DATABASENAME’,
  'username' => ‘USERNAME’,
  'password' => ‘PASSWORD’,
  'prefix' => '',
  'host' => 'localhost',
  'port' => ‘PORT’,
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

We have used “External” for connecting to Drupal 6 database. “Default” is used for Drupal 8 database connection. So now there will be 2 database connections in settings.php

Code to switch to Drupal 6 database connection:

    // Switch to external database
\Drupal\Core\Database\Database::setActiveConnection('external');

// Get a connection going
$db = \Drupal\Core\Database\Database::getConnection();

Database Query to fetch locations from Drupal 6 database:

// Query to fetch all locations
  $query = $db->select('location', 'l');
  $query->join('location_instance', 'li', 'l.lid = li.lid');
  $query->fields('l', array('name', 'street', 'additional', 'city', 'province', 'postal_code', 'country', 'latitude', 'longitude'));
  $query->fields('li', array('nid', 'vid'));
  $location = $query->execute()->fetchAll();

Switch back to Drupal 8 database connection:

// Switch back
\Drupal\Core\Database\Database::setActiveConnection();

Code to update locations in Drupal 8 database: 

 // Query to import locations
  $last_location = count($location);
  foreach ($location as $key => $value) {
    // UK code is changed to GB in Drupal 8
    if ($value->country == 'uk') {
      $value->country = 'GB';
    }
    $node = node_load($value->nid);
    
    db_merge('node__field_location')
      ->key(array('entity_id' => $value->nid))
      ->fields(array(
          'bundle' => $node->getType(),
          'deleted' => '0',
          'entity_id' => $value->nid,
          'revision_id' => $value->vid,
          'langcode' => 'en',
          'delta' => '0',
          'field_location_address_line1' => $value->name,
          'field_location_address_line2' => $value->street,
          'field_location_locality' => $value->city,
          'field_location_postal_code' => $value->postal_code,
          'field_location_country_code' => strtoupper($value->country),
      ))
      ->execute();

    db_merge('node_revision__field_location')
      ->key(array('entity_id' => $value->nid))
      ->fields(array(
          'bundle' => $node->getType(),
          'deleted' => '0',
          'entity_id' => $value->nid,
          'revision_id' => $value->vid,
          'langcode' => 'en',
          'delta' => '0',
          'field_location_address_line1' => $value->name,
          'field_location_address_line2' => $value->street,
          'field_location_locality' => $value->city,
          'field_location_postal_code' => $value->postal_code,
          'field_location_country_code' => strtoupper($value->country),
      ))
      ->execute();

    // Show a message on screen once all the locations are updated.
    if ($key == ($last_location - 1)) {
      drupal_set_message('Migrated locations');
    }
  }

Note: I had same nids on drupal 6 & drupal 8 site as i used drupal 8 core migration.
  
4. Run Cron to import all locations.

Here is the full code written in hook_cron():

function MODULENAME_cron() {
  // Switch to external database
  \Drupal\Core\Database\Database::setActiveConnection('external');

  // Get a connection going
  $db = \Drupal\Core\Database\Database::getConnection();

  // Query to fetch all locations
  $query = $db->select('location', 'l');
  $query->join('location_instance', 'li', 'l.lid = li.lid');
  $query->fields('l', array('name', 'street', 'additional', 'city', 'province', 'postal_code', 'country', 'latitude', 'longitude'));
  $query->fields('li', array('nid', 'vid'));
  $location = $query->execute()->fetchAll();

  // Switch back
  \Drupal\Core\Database\Database::setActiveConnection();

  // Query to import locations
  $last_location = count($location);
  foreach ($location as $key => $value) {
    // UK code is changed to GB in Drupal 8
    if ($value->country == 'uk') {
      $value->country = 'GB';
    }
    $node = node_load($value->nid);
    
    db_merge('node__field_location')
      ->key(array('entity_id' => $value->nid))
      ->fields(array(
          'bundle' => $node->getType(),
          'deleted' => '0',
          'entity_id' => $value->nid,
          'revision_id' => $value->vid,
          'langcode' => 'en',
          'delta' => '0',
          'field_location_address_line1' => $value->name,
          'field_location_address_line2' => $value->street,
          'field_location_locality' => $value->city,
          'field_location_postal_code' => $value->postal_code,
          'field_location_country_code' => strtoupper($value->country),
      ))
      ->execute();

    db_merge('node_revision__field_location')
      ->key(array('entity_id' => $value->nid))
      ->fields(array(
          'bundle' => $node->getType(),
          'deleted' => '0',
          'entity_id' => $value->nid,
          'revision_id' => $value->vid,
          'langcode' => 'en',
          'delta' => '0',
          'field_location_address_line1' => $value->name,
          'field_location_address_line2' => $value->street,
          'field_location_locality' => $value->city,
          'field_location_postal_code' => $value->postal_code,
          'field_location_country_code' => strtoupper($value->country),
      ))
      ->execute();

    // Show a message on screen once all the locations are updated.
    if ($key == ($last_location - 1)) {
      drupal_set_message('Migrated locations');
    }
  }
}

Hope this code helps you to make things work..!!! Need more assistance regarding web development service...!

Jan 05 2017
Jan 05

Working with Drupal, often times we are required to import a large set of data in site. We have various ways to import data. Feeds module is simple and easy to use. Feeds out of the box supports many features which can cover a variety of scenarios. The module is well documented and you can access documentation here.

In this part, we are going to explain basics for how to import data using feeds.

To use feeds module, we need ctools and job scheduler module enabled.

The first step in the process is to turn required modules enabled. Enable Feeds, Feeds Admin UI. If you want an example of node importer and user importer then turn Feeds Import enabled.

Data Migration Through Feeds

Next step is to add an importer that lets you import data. To do this, go to "admin/structure/feeds" and click on "Add importer". If you have turned Feeds Import on, you will see example importers here.

Data Migration Through Feeds

Next step is to configure importer. There are various parts in this.

  1. Basic Settings
  2. Fetcher
  3. Parser
  4. Processor

Each is explained in detail below:

Data Migration Through Feeds

Basic Settings

Data Migration Through Feeds

These are basic settings for importers: 

Name and description are what you specified while creating the importer. "Attach to content type" is used to determine whether we want to attach importer to any content type form or use standalone form.  

We use the standalone form if we want to import by using a form that comes with the module at /import path. If we go with content type then import is executed by creating a node of selected content type.

Periodic updates are used to run import periodically. Proper cron configuration is required to run periodic updates. Keep periodic updates off if you are importing data one time only.

Import on submission will start importing process as soon as the form is submitted. There is an option to run the process in the background. This is particularly helpful when importing large data.

Fetcher

The Fetcher is where your feed is fetched from. We have two options here: File upload and HTTP fetcher.

Data Migration Through Feeds

File upload is where we upload the file from the local system. HTTP fetcher is where we provide content from URL. For this example, we are going with file upload. Each fetcher has its own settings.

Data Migration Through Feeds

For file upload fetcher, you can decide which types of file extensions are allowed and where uploaded files should be saved.

Parser

Parser determines the format of data. Options include following:

Data Migration Through Feeds

We are going with CSV parser for this example.

Processor

This determines what type of data we are importing. Options includes following

Data Migration Through Feeds

Node processor:  creates nodes upon import
Taxonomy term processor: created taxonomy terms upon import
User processor: creates users upon import

For this example, we are using node processor.

Node processor setting

Data Migration Through Feeds

These settings are used to decide how the processor will work. Each setting here impacts on what happens when import runs.

Bundle: This is what type of node want to create when import runs. Based on selected content type, we can create a mapping in next step.

Insert new nodes: Based on selection, new nodes are inserted based on unique key in mappings.

Update existing nodes: If unique key is repeating then based on selection existing nodes are updated, replaced or left untouched. This is particularly handy when we are using the same importer more than once.

Text format: This determines the format of text fields in selected node type. If you have HTML content, it's better to go to with Full HTML format.

Action to take when previously imported nodes are missing in the feed: This determines what to do when previously imported nodes are missing from current feed.

Author: The author of imported nodes. Leaving this empty will make anonymous user author of node. You also can make sure that user has permission to add this type of content with  Authorize checkbox.

Expire Nodes: Keep this set to never if you want do not want to delete imported nodes. Nodes will be deleted after selected time otherwise.

Mapping

Data Migration Through Feeds

This is where we determine which CSV column belongs to which field of content type. In custom drupal development, This is very important to match correct fields. For this example, we are adding title and body. The title is made unique field. Based on this and settings in the previous step, new nodes will be imported or updated.

The importer is ready and we can start importing nodes. Since we are using standalone form, we need to goto /import and upload CSV file as per our settings

Data Migration Through Feeds

Select the importer we just created.

Data Migration Through Feeds

We get a template sample on this page which helps in CSV file construction. Upload the CSV file in required format and import content. Upon completion, a status message is displayed.

In case, we want to delete all nodes that we imported we can do so by going to "Delete Items" tab on import page.

Feeds module out of the box provides many features and is very powerful. There are various other modules available that enhances feeds module functionality.

Hope this helps you, feel free to share your valuable feedbacks and inputs.

Dec 27 2016
Dec 27

Make multidomain work in multilingual site

The website we manage uses multilingual features. We have this site in 3 different languages. Language detection is done using URL.

Recently, the requirement came up to make subdomain on this site.

The following is step by step guide to create subdomain and make it work with multi language.

1 - Download module

Download and enable Domain access module and enable it.

You will receive an error  "domain access failed to load during the bootstrap phase".

Subdomains with multilingual sites

You have two options to solve this issue.

Option 1:

Copy following code in your settings.php

 /**
     * Add the domain module setup routine.
     */
    include DRUPAL_ROOT . '/path/to/modules/domain/settings.inc';

Make sure to replace "/path/to/modules/" to directory in which domain module is present. Normally it is "sites/all/modules".

Option 2:

If you are having difficulty determining the correct path, copy the following files into your settings folder.

domain > domain.bootstrap.inc
domain > settings.inc
domain > settings_custom_url.inc
The files should be in the same directory as your active settings.php file.

Then add the following lines:

/**
 * Add the custom_url_rewrite_outbound function.
 */
include 'settings.inc';

More details available here or you can hire drupal developer for help.

2 - Add domain

Navigate to "admin/structure/domain/create" and create domain.

Subdomains with multilingual sites

3 - Configure domain

To have domain specific configurations, you need to have Domain Configuration and Domain Settings sub modules enabled. Enabling this module allows you to have different settings on each domain. These settings include domain email address, site slogan, front page, menu settings etc.

Subdomains with multilingual sites

4 - Theme setting for domain (optional)

If you want your subdomain to have separate theme, you need to enable Domain Theme submodule. This module allows you to set theme for subdomain.

Subdomains with multilingual sites

5 - Set multi language for domain

Imagine a scenario where we have multilingual sites with domains de.example.com and en.example.com. Now, we want to create subdomains for this site. These subdomains will have URL like this: test.de.example.com and test.en.example.com.

Both de.example.com and test.de.example.com are in german language. Similarly, both en.test.com and test.en.example.com are in english language.

To implement this, we need to use Language MultiDomain module. Along with this module we need to use patch from here to make this work properly.

Once this module is enabled, navigate to "admin/config/regional/language" and edit language and set multiple domains in "Language Domain"

Subdomains with multilingual sites

Save and you are done. Now you have 4 domains.
 

That's so easy now :) Feel free to catch more quick solution blogs and your feedbacks would be very valuable. 

Dec 08 2016
Dec 08

Twig is a php template engine used in drupal 8. It is fast, secure and flexible. Template files and theme functions is replaced by *.html.twig template files in D8.

{{ }}

Print statement

{# #}

Comment statement

{% %}

Execution statement (Ex. for-loops)

{% set foo = 'bar' %}

Sets variable “foo” with value “bar”

{% set foo, bar = 'foo', 'bar' %}

Sets Multiple variable at a time.

This is equivalent to

{% set foo = 'foo' %}

{% set bar = 'bar' %}

{% set foo = [1, 2] %}

Set array “foo” with values “1” & “2”

{% set test = {'foo': 'bar'} %}

Set array “test” with key as “foo” & value as “bar”

{% set c = a ~ b %}

Concatenates string “a” & “b”. operands are converted into strings.

{{ dump(user) }}

Prints array if “user” is an array

if it is a variable then it will print variable value.

{{ dump(user|keys) }}

Prints “key” of “user”.

  1. Filters are separated by pipe symbol (|)
  2. Multiple filters can be chained
  3. Optional arguments appear in parentheses

{{ name|striptags|title }}

“striptags” removes all HTML tags from “name” and “title” title-cases it.

{{ 'temperature is less than 18'|t }}

“t” is used for translation of string

{{ list|join(', ') }}

Join list with comma(,)

{{ "now"|date('d/m/Y H:i', timezone="Europe/Paris") }}

Render “now”date with specific format and specific timezone

          Example:

<ul>
  {% for key, user in users %}
        <li>{{ user.username|e('html') }}</li>
  {% else %}
        <li><em>no user found</em></li>
  {% endfor %}
</ul>
  • If Condition

Example 1:

{% if temperature < 18 %}
<p>{{ 'temperature is less than 18'|t }}</p>
{% elseif temperature > 18 and temperature < 27 %}
<p>{{ 'temperature is between 18 & 27'|t }}</p>
{% else %}
<p>{{ 'temperature is greater than 18'|t }}</p>
{% endif %}

Example 2:

{% if users | length > 0  %}
        <p>There are {{ users | length }} users available.
{% endif %}

In this example, if there are users available, then it will print the number of users available.

{{ foo ? 'yes' : 'no' }}

If “foo” is set then it will return “yes” else “no”

{{ foo ?: 'no' }}

same as {{ foo ? foo : 'no' }}

{{ foo ? 'yes' }}

same as {{ foo ? 'yes' : '' }}

{{ foo ?? 'no' }}

if “foo” is defined and not null then it will return “foo” else “no”

{{ "foo #{bar} baz" }}

Value of #{bar} is replaced in the string

{{ "foo #{1 + 2} baz" }}

#{1 + 2} expression is evaluated and replaced

  1. Manually escaping

{{ user.username|e }}

{{ user.username|e(‘html’) }}

Default is “html” escape

{{ user.username|e('js') }}

Escape JS

{{ user.username|e('css') }}

Escape CSS

{{ user.username|e('url') }}

Escape URLs

  1. Automatically escaping

{% autoescape %}
   Automatically escaping text.
{% endautoescape %}

Default is “html” escape

{% autoescape 'js' %}
   Automatically escaping text.
{% endautoescape %}

Auto Escape ‘js’

{% include 'header.html.twig' %}

This is used to include “header.html.twig” in any other file.

{% macro input(name, value, type, size) %}
        <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
{% endmacro %}

In above example “Type” default value is set to “text” and “size” default value to “20”. It can also be defined as:

{% macro input(name, value = "", type = "text", size = 20) %}
<input type="{{ type }}" name="{{ name }}" value="{{ value|e }}" size="{{ size }}" />
{% endmacro %}

Import macro in different file, and then use it:

{% import "forms.html" as forms %}
<p>{{ forms.input('username') }}</p>


  • Import individual macro names with alias:
{% from 'forms.html' import input as input_field %}
<p>{{ input_field('username') }}</p>


  • Import macro into same file:
{% import _self as forms %}

Hope this helps you all. Feel free to leave valuable feedbacks regarding the same. 

Nov 23 2016
Nov 23

Drush is a command line tool built to assist you in working with Drupal from the terminal. It comes by default with a bunch of useful commands, such as downloading, enabling or even updating modules.

With drupal, drush can be extended. It is really simple and everyone can write their own drush commands. As an example, I am going to show you how you to trigger a node save.

First, we will need a drush command file. The drush command file must end with .drush.inc.

It can be placed in a number of locations.

1. Drush folder in your home directory: ~/.drush. If you put the drush command file in that directory, your commands will be available for all your projects.

2. Inside a module: Add your command file to the module folder. This is more preferable if the command functionality is specific for a project.

In this file, we are going to implement the hook_drush_command() hook. This hook defines the drush command.

File: mymodule.drush.inc

Hook function: mymodule_drush_command()

<?php
function MYMODULE_drush_command() {
  $items  = array();
  $items['nodecreate'] = array(
    'callback'    => 'custom_drush_create_node',
    'description' => dt('Triggers a node-save'),
    'aliases' => array('nc'),
    'arguments'   => array(
      'title'     => "Title of node",
    ),
    'options' => array(
      'repeat' => 'Number nodes to create.',
    ),
    'examples' => array(
      'drush nc error' => 'Prints error as node title is blank.',
      'drush nc Test --repeat=5' => 'Creates 5 nodes with title Test.',
    ),
  );
  return $items;
}

Running the Drush help command for our own command drush help nc will list some useful information about this command (arguments, options, description, aliases, examples etc)

Callback Function

As we have written callback function, Drush expects a function to be declared called drush_create_node(). This default naming structure starts with drush followed by the name of the command all connected with underscores.

function MYMODULE_create_node($title) {
  $repeat = drush_get_option('repeat', 1);
  for ($i=0; $i < $repeat; $i++) {
    $node = new stdClass();
    $node->type = "page";
    $node->title = $title;
    $node->language = LANGUAGE_NONE;
    $node->uid = 1;
    $node = node_submit($node);
    node_save($node);
  }
  drupal_set_message(t('Created ' . $repeat . ' node with title ' . $title));
}

Now clear the drush cache: drush cc drush

And run command: drush nc OR drush nodecreate

Arguments and options

-> Arguments are mandatory whereas options are not.

-> Arguments are passed as function parameters (in order) while options are retrieved in the callback using a special helper function (drush_get_option).

We declared 1 argument (called title) and one option called repeat.

-> The argument type will be the first string that gets written after the command name in the terminal (drush nodecreate or drush nc).

-> The option will be an integer value that gets assigned to the --repeat flag in the command.

Ex. drush nc Test --repeat=2

This will create 5 nodes, with title “Test”

User input

Let’s make it so that if a user doesn’t pass an argument, we ask them what argument they’d like to pass and use the value they provide interactively.

This goes to the top of the command callback function before checking whether the correct argument was passed.

// Check for existence of argument
if (!$title) {
  $options = array(
    'Test' => t('Test'),
    '0' => t('Error'),
  );
  $title = drush_choice($options, t('Please choose a option.'));
}
…
  1. Everything happens only if the user has not passed an argument.
  2. We create an array of key-value pairs that will represent the choices we give the user. The array keys represent the machine name of the choice while the values, the human readable name.
  3. We pass this array along side a question string to the drush_choice() function that will return the machine name of the choice the user makes. And that becomes our new $title variable (the argument).

If the title is not set or error is returned, we can add code to print error in terminal.

…
  if(!$title || $title='error') {
    drupal_set_message(t('Error! No title set.'));
  }
…

Full Code will look something like this:

<?php
 
function MYMODULE_drush_command() {
  $items  = array();
  $items['nodecreate'] = array(
    'callback'    => 'custom_drush_create_node',
    'description' => dt('Triggers a node-save'),
    'aliases' => array('nc'),
    'arguments'   => array(
      'title'     => "Title of node",
    ),
    'options' => array(
      'repeat' => 'Number nodes to create.',
    ),
    'examples' => array(
      'drush nc error' => 'Prints error as node title is blank.',
      'drush nc Test --repeat=5' => 'Creates 5 nodes with title Test.',
    ),
  );
  return $items;
}
 
function MYMODULE_create_node($title) {
  if (!$title) {
    $options = array(
      'Test' => t('Test'),
      '0' => t('Error'),
    );
    $title = drush_choice($options, t('Please choose a option.'));
  }
  if(!$title || $title='error') {
    drupal_set_message(t('Error! No title set.'));
  }
  else {
    $repeat = drush_get_option('repeat', 1);
    for ($i=0; $i < $repeat; $i++) {
      $node = new stdClass();
      $node->type = "page";
      $node->title = $title;
      $node->language = LANGUAGE_NONE;
      $node->uid = 1;
      $node = node_submit($node);
      node_save($node);
    }
    drupal_set_message(t('Created ' . $repeat . ' node with title ' . $title));
  }
}

Feel free to drop your any queries/concern related to this blog. For Drupal Web Development we are always ready to help :) Stay tuned! 

Nov 23 2016
Nov 23

Can it get better than a fantabulous amalgamation of technology, human interaction, community service and a surreal location? Certainly not! Precisely that’s when you realize DrupalCon is calling you and all you need to do is get ready for some mesmerizing interactions, action-packed 7 days, prolific exchange of ideas and lifelong memories.

If there’s one place where learning meets party then it is certainly at DrupalCon. Held thrice a year, this conference has the globe getting united by a wonderful open source tool called Drupal. The purpose of this conference is simple – Enhancement & Empowerment – enhancement of technologies, platforms, to empower the end product.

When one has so much to explore and gain, who would want to give it a miss? That’s why AddWebSolution is all geared up to add 3rd DrupalCon to its list, after attending the first two at DrupalCon Los Angeles, California, USA, May 11 - 15, 2015 and DrupalCon Asia, Mumbai, India, February 18 - 21, 2016 respectively.

DrupalCon LA & DrupalCon Asia Memories

For those who missed us at the previous two events take a lookCommunity.

DrupalCon Dublin 2016

As we at AddWebSolution get charged up for DrupalCon at Dublin, we share with you our “Bucket List” for the city of Dublin.

With a population of 1.5 million, the Irish capital city Dublin is nestled on Ireland’s east coast on the river Liffey. A perfect concoction of the old and new, Dublin never fails to delight its visitors.

With Irish coffee topping our “To Do” list, here’s where we would set out to explore.

  1. Guinness Storehouse
  2. Dublin Zoo
  3. National Aquatic Center
  4. The National Gallery of Ireland
  5. National Museum

Nah, this isn’t the end. We have a few more which can be found here

What’s in store for you at DrupalCon Dublin 2016?

With estimated 2000+ attendees, the countdown to the biggest event has begun with merely 17 days to go from now and would include summits, Workshops, Training sessions, sprints, Keynotes – everything “For Drupal and By Drupal”

For a detailed conference plan, visit here. It’s time we give back to the community!

With this as the driving force, AddWebSolution is proudly attending DrupalCon Dublin as one of the Sponsors and we cannot express what it feels when we are on the paths of #givingback to the community.

As we climb the ladder of success, we also strive to expand our competence of community service and giving back. Hence we progressed from attendees to volunteers and now as sponsors. This is a small way by which we express our gratitude to the global Drupal community and its offerings to technology evangelists like us.

Come, Meet us.

We would be exhibiting on Wednesday i.e 28 September, 2016 and would be available at Booth No. 603 from 9 AM to 6 PM with some great Indian flavor ☺

Do not forget to grab some interesting freebies. Be ready for more surprising elements!!

Our joy knows no bounds as we await 5 days of collaborative brainstorming, creative thinking, knowledge sharing, meeting old friends, renewing old ties and making new friends.

See you at Dublin then!

Nov 23 2016
Nov 23

What if anyone needs to use existing fields added from backend to a custom form ?

After lots of research I found a drupal hook which can fulfil this requirement. Please read below to add an existing field to your custom form.

Benefits of using field attached form

  1. Field will be generated automatically
  2. Validation will be performed same as admin side
  3. Store value is easy for the same

I have a fields for ‘test’ content type, named Image (field_test_image).

Please find below how can I use my existing fields to my custom form. This is how I took my fields for my content type.

Using drupal existing fields to custom form

Below is code to use field attached form hook.

/** * Implements hook_form() */ function hook_form($form, &$form_state) { $entity_type = 'node'; $entity_info = new stdClass(); $entity_info->type = 'test'; $field = 'field_test_image'; //to attach test content type's field to the form field_attach_form($entity_type, $entity_info, $form, $form_state, NULL, array('field_name' => $field)); $form['submit'][] = 'hook_custom_submit'; return $form; } /** * Implements hook_submit() */ function hook_custom_submit($form, $form_state) { $form_values = $form_state['values']; $node = new stdClass(); $node->type = 'test'; $node->field_test_image = $form_values[‘field_test_image’]; node_save($node); }

 Hope this helps you to understand and resolve the problem. We are Professional Web Development  free to contact us for any issues. 

Nov 23 2016
Nov 23

Using Apache solr we can make a powerful search technology for websites. This can be done using faceted search.

Facet search allows us to make search blocks for author, category and other custom fields.

Let's assume that we need to add a select filter for width field.

Create custom (i.e example) module for the same

Add below code in info file:

files[] = plugins/facetapi/custom_widget.inc

Example code of example.module file

How to build your own facet widget?

To build our own custom facet widget, we will need to implement hook_facetapi_widgets. This will add "custom select" option in display widget option as show in screenshot.

Drupal 7 Custom Display Widget for Solr Search
<?php



function example_facetapi_widgets() {
  return array(
    'example_select' => array(
      'handler' => array(
        'label' => t('Custom Select'),
        'class' => 'CustomFacetapiWidgetSelect',
        'query types' => array('term', 'date'),
      ),
    ),
  );
}


Example code of custom_widget.inc ( plugins/facetapi/custom_widget.inc)

Here we have created custom class "CustomFacetapiWidgetSelect" which is binded from hook_facetapi_widgets function. Using this class we can fill fields value and define form which will be displayed using search block.

<?php


/**
 * Widget for range filtering.
 */
class CustomFacetapiWidgetSelect extends FacetapiWidget {


  /**
   * Overrides FacetapiWidget::__construct().
   *
   * Use facet machine name instead of the alias; @see FacetapiWidgetLinks.
   */
  public function __construct($id, array $realm, FacetapiFacet $facet, stdClass $settings) {
    parent::__construct($id, $realm, $facet, $settings);
    $this->key = $facet['name'];
  }


  /**
   * Renders the form.
   */
  public function execute() {


    $elements = &$this->build[$this->facet['field alias']];


    $elements = drupal_get_form('example_facetapi_widgets_select_form', $elements);
  }
}
?>

Now we will need to create custom form which will be displayed on search block.
We need to create form 'example_facetapi_widgets_select_form' as per below. Using below function we will able to display select search block as displayed in screenshot.

Here I have handled form submission through ajax callback function.

<?php 


/**
 * Generate form for facet.
 */
function example_facetapi_widgets_select_form($form, &$form_state, $elements) {


  // Build options from facet elements.
  $default_select_value = '';
  $options = array('' => t('- Select -'));


  foreach ($elements as $element) {


    $ele_key = serialize($element['#query']);
    if ($element['#active']) {
      $default_select_value = $ele_key;
    }
    $options[$ele_key] = $element['#markup'] . ' (' . $element['#count'] . ')';
  }


  $form['select'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#attributes' => array('class' => array('custom-solr-filter-select')),
    '#default_value' => $default_select_value,
  );


  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Go'),
    '#attributes' => array('class' => array('custom-solr-filter-submit')),
    '#suffix' => '</div>',
  );


  //$form['#submit'][] = 'aq_solr_alter_facetapi_select_form_submit';


  $form['submit']['#ajax'] = array(
    'callback' => 'example_facetapi_widgets_select_form_callback',
  );


  return $form;
}


/**
 * Callback function for facetapi custom form
 * Redirect to the filtered page
 */
function example_facetapi_widgets_select_form_callback($form, $form_state) {


  //build new query
  $new_query = unserialize($form_state['values']['select']);


  //ajax redirection
  ctools_include('ajax');
  ctools_add_js('ajax-responder');
  $commands[] = ctools_ajax_command_redirect('search', 0, array('query' => $new_query));
  print ajax_render($commands); exit;
}


?>



After configuring search block to the needed page width fields filter options will be displayed as shown in the screenshot and also this will filter listing on selection particular value as shown in the screenshot.

Drupal 7 Custom Display Widget for Solr Search Drupal 7 Custom Display Widget for Solr Search

Hope you had a better clarity with my explanation, feel free to share your feedback and keep tuned in for more blogs. Get in touch with us for any Drupal Web Development Services :) 

Nov 23 2016
Nov 23

Views Tabs Field 

This module provides a field of Views which renders content in vertical or horizontal tabs. This allows us to show content on views page in the tabbed format. This module provides a field in view which can be used to show content on tabs.

Below are the steps to use this module.

1 - Download and enable module normally.

2 - Create a view and add fields in this view. The fields that you want to be displayed as tabs, make them exclude from a display.

3 - Add "Global: Tabs" field.

How To Use Views Tab Fields In Drupal

4 - Choose type of tabs you want : Horizontal Tabs or Vertical Tabs

Tabs Selection

5 - Under tabs, add as many tabs as you want. In Tab content, add fields from replacement pattern. You can add HTML in this as well.

Tabs Content

6 - Save the view. The final result is something like this depending upon which types of tabs you selected.

Tab Fields In Drupal

Hope this blog was very useful for you guys. Leave your comments and feedbacks. 

Nov 23 2016
Nov 23

So you guys could not make it to the DrupalCon Dublin 2016. We must admit that you did certainly miss a lot of action. Nevertheless, as promised, here is a recollection of everything that made DrupalCon Dublin so very special.

How often does one get a chance to jazz up the start to their day with games, singalong activities and some feet thumping Irish Dance? This is how Dublin welcomed us, warmed-up us and ensured we were all geared up for five days of learning, fun and community service. Day 1 gave us good insights about the ever adaptive Drupal and how it has changed since the release of its version 8. It also highlighted the fact that why Drupal still remains the most preferred open source and endless opportunities it offers which are yet to be explored. It reinforced our belief in the technology and AddWeb Solution’s constant endeavors to use this technology for the betterment of our clients’ businesses. The same day also offered us an opportunity to think business from different perspective and recycle an obsolete idea into a profit-making business line. Business Summit as they called it made us really work on our Grey Matter; where we had to discuss our Business ideas with C Levels and guess what? It paid-off! The team we were a part of, won the competition titled 'Turn Worst Business Idea into Best' with the crazy topic ‘Criminal Coders’. Day 2 started with #DriesNote and offered us great learning when different organizations put forth their exhibits and presentations widening our prospects of understanding Drupal from a client’s and the organization’s perspective. While the days were busy with serious learning and sharing, the evenings gave us the parties, exploring Dublin and some out-of-the-world gastronomical indulgences among the Boat parties with some old friends and obviously networking with the new ones. Day 3 & 4 was what makes Drupal special – a community which is bonded with the sole purpose of “Community Service” and “Giving back”. With quizzes, fun sessions and talks, the event concluded on a highnote for us. The moment of pride for AddWeb Solution was when we could pat our backs for Community Service not only through our intellect but also by being one of its Sponsors. Another experience which made our 3rd day extremely special was when the visitors to the Exhibition booth showered on us praises and compliments like Most Colorful & Lively Booth in the entire DrupalCon Exhibition!

Last day made us thank Heavens for not missing out on DrupalCon at Dublin which was all about sprints and the sprinter workshop and we were fortunate to meet the Evangelist herself – our lovely Angela Byron and witness her in action LIVE!

While Drupal kept us on our toes from morning to evening, the beauty and magnificence of Dublin left us awestruck whenever we explored it. Amidst the classical structures of Dublin which date back to centuries, the contemporary modern day structure Convention Centre Dublin around river the river Liffey– which was also the venue to the event, was one of the most amazing structures ever witnessed.

Did we mention our visit to Guinness Storehouse? Well, you need to visit to feel it :-D

Instead of being just another community gathering, DrupalCon Dublin 2016, got us to imbibe more, experiment more, enjoy more and also to contribute more! Our big thanks to organizers, volunteers, mentors and the Drupal Community as a whole who made this event a great success!

As we put to practice the insights of these exciting three days, we look forward to again contribute in all possible way to DrupalCon 2017 Baltimore, USA to make it bigger and better. Hope to see you there ☺

Nov 23 2016
Nov 23

Drupal 8 was released in November 2015, since then its adoption has picked up quite a lot of pace, it is the new standard for creating incredible digital experience, it is considered to be a massive improvement over Drupal 7 with plethora of new features built in. It is said that Dries and other team members have put in unprecedented amount of efforts for more than 5 years to build D8. Drupal 8 is built by phenomenal efforts of 3290 contributors & 1228 companies.

Let’s learn more about the massive improvements and fantastic features of D8.

Configuration Management - Drupal 8’s configuration system handles all kinds of config settings, and you have options for how and where you store your data. By default, both global and itemized settings are stored, in a standard format, in the database. But you can change that. Choose Drupal UI, Drush, or file-based workflows. You can also export your config data into YAML files to manage it with version control. And, if you need to, you can override config data in your settings.php file.

Multilingual Support - Drupal 8 boasts extensive multilingual features right out of the box. The admin interface has built-in translations. You can also create pages with language-based Views filtering and block visibility. Translation updates from the community are automatically facilitated. provides 4 core modules specifically for language and translation support. Build what you want, with the languages you know best.

“Views” in the Core - Another great feature of D8 is Views in Drupal Core. This and a great and long-awaited change. This simplifies things when clients need to customize things like the content list page. With this Drupal 8 feature, Views is part of and firmly integrated with the core. The front page and several administration pages are now Views, and users will now be able to create quickly pages, blocks, admin sections, etc., and modify existing ones just as effortlessly.

Theming Engine – Drupal 8 boasts “TWIG” based theming engine, Twig is a template engine for PHP and it is part of the Symfony2 framework. In Drupal 8 Twig replaces PHPTemplate as the default templating engine. One of the results of this change is that all of the theme_* functions and PHPTemplate based *.tpl.php files have been replaced by *.html.twig template files. It’s much easier to create beautiful and more functional Drupal websites using Twig.

Responsive Out-of-the Box - Drupal 8 is fully responsive. That is, you can install a Drupal 8 website from any device and any resolutions. Drupal 8 is mobile-first in its approach. All the built-in themes that come with Drupal 8 are responsive, along with an admin theme that adapts to different screen sizes, and a ‘Back To Site’ button to go back to the front page. Integration of the Picture and Breakpoint module ensure that images are optimized for each device. You can also create a different layout via an interface for each resolution.

Webservices - As with multi-lingual sites, it used to require several contributed modules to create a webservice in Drupal 7. Now, in Drupal 8, everything you need is in the core. Enable the four Web Services modules, go to Views, and you'll immediately be able to create a REST export. Hypertext Application Language (HAL) is implemented in Drupal 8 and makes exploitation of web service capabilities less painful.

This of course is only equivalent to scratching a surface, Drupal 8 is very technically advanced version of Drupal, in the 90 days following the release of Drupal 8.0.0, adoption has outpaced Drupal 7 by more than 200 percent, this speaks a lot about rising popularity of this version. A survey conducted by Dries mentions that top two reasons people say they haven't upgraded to Drupal 8 yet are (1) the fact that they are waiting for contributed modules to become available and (2) they are still learning Drupal 8. It has only been 7 months until now, and Drupal 8 is running on more than 100,000 sites. From what we sense, this version is definitely going to be a game changer, it’s only a matter of time!

Nov 23 2016
Nov 23

As we all know, Drupal 8 having Symfony framework is making a great way with many changes/tweaks carried out into it.

There are many contributed modules available in Drupal 7 but do not exist yet for Drupal 8, so to migrate respective modules from Drupal 7 to Drupal 8 here’s the quick and easy steps which would lead towards success.

1) Copy paste D7 module to D8 directory.

- The folder structure for D7 was /sites/all/modules which is changed to /modules.

2) Convert your .info file:

  1.  If you visit the Drupal 8 module administration page at admin/modules, you will notice that your module is not listed. In order for Drupal 8 to detect your module, you will need to update the module's .info file to a new YAML format.
  2. Rename mymodule.info to mymodule.info.yml
 -- You can reuse the existing .info file and then convert it. Rename your mymodule.info file to mymodule.info.yml.
    -- Convert the file to the new YAML format
      --- For the most part, change all = to :
      --- For arrays (e.g. dependencies[] = node), use the following format in drupal 8:
            dependencies:
              - node
          ---- Replace 
                Drupal 7
                  stylesheets[all][] = css/layout.css
                  stylesheets[all][] = css/style.css
                  stylesheets[print][] = css/print.css
                Drupal 8
                  stylesheets:
                    all:
                      - css/layout.css
                      - css/style.css
                    print:
                      - css/print.css
          ---- Replace 
                Drupal 7
                  regions[header] = Header
                  regions[help] = Help
                Drupal 8
                  regions:
                    header: Header
                    help: Help
  • In drupal 7 we use ; for Comments And now in drupal 8 we use # for Comments.
  • ‘type’ is required. It indicates the type of extension. Values: module, theme or profile. For example: type: module
  • Remove files[] entries.
  • Convert configure links to route names
 In Drupal 8, specify route name instead of the system path.
            Drupal 7
              configure = admin/config/system/actions
            Drupal 8
              configure: action.admin

  • Change "core" & "Version" accordingly
  • Once you've converted the file, reload admin/modules and Enable your module.
  • Debugging .info.yml: If the module is not listed on modules page or you cannot enable the module, see the troubleshooting tips

3) Convert hook_menu():

  • Create module.routing.yml file
  • Routes in D8 are defined in module.routing.yml files in YAML format. This was previously defined in hook_menu().
  • Machine name for route should be module_name.sub_name. - The path has to be added to route e.g. /admin/test. Do not forget to add preceding slash.
  • _content will be pointing to the callback function and return of page callback is rendered inside a block.
  • Use _controller when you don’t want to render a fully themed HTML page.
  • _controller or _content keys may point to a function or a method of a class.

Ex: _content: \Drupal\MYMODULE\Controller\MYCLASS::MYMETHOD - hook_menu_alter() is no longer used.  

Ex.

   # Drupal 7 menu item
      $items['admin/test'] = array(
        'title' => 'Tests',
        'description' => "Test description.",
        'page callback' => 'test_admin_callback',
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
        'file' => 'test.admin.inc',
      );

# Drupal 8 test.routing.yml snippet

 test.admin:
        path: '/admin/test'
        defaults:
          _controller: '\Drupal\test\Controller\TestController::adminOverview'
          _title: 'Tests'
        requirements:
          _permission: 'access content'

- Explanation of various parts:

test.admin: This is route machine name (module_name.sub_name). Other parts of code should use the machine name to refer to route.

  • path: Path of page. Do not forget to add leading slash (/)!
  • defaults: Page & title callbacks
  • requirements: Conditions to display the page (Permissions, module dependency etc).
  # Drupal 8 TestController.php
      /**
       * @file
       * Contains \Drupal\test\Controller\TestController.
       */

      namespace Drupal\test\Controller;

      use Drupal\Core\Controller\ControllerBase;

      /**
       * Controller routines for test routes.
       */
      class TestController extends ControllerBase {

        /**
         * Returns an administrative overview of test.
         *
         * @return array
         *   A render array representing the administrative page content.
         */
        public function adminOverview() {
          // ...
        }
      }

Explanation of various parts:

  • namespace This declares the prefix needed to fully qualify the name of the class we are defining.
  • use This allows to use ControllerBase instead of fully qualified name.
  • adminOverview() public method should be defined which return a renderable array.
  • Main components to make the route work: path and controller
  • We have provided ‘permission’ in 'requirements' section. so if visitor access the page '/admin/test' and have the permission to access content, then the output will be generated based on that method on the TestController class.
  • Reference for more details: https://www.drupal.org/node/2118147

4) drupal_valid_path is changed to PathValidator service:

    D7
    $is_valid = drupal_valid_path($path);

    D8
    $is_valid = \Drupal::service('path.validator')->isValid($path);

5) module_exists($module) is deprecated in Drupal 8:

- Use Drupal::moduleHandler()->moduleExists($hook).

6) Convert form, form_submit & form_validation functions:

- In Drupal 7, forms were built by a procedural function. Validation and submission were handled by following names: the name of your form function, followed by either _validate or _submit.

- Use: return drupal_get_form(FORMID);

- In Drupal 8, there is an interface called FormInterface.

- It has four methods:

  • getFormID()
  • buildForm()
  • validateForm()
  • submitForm()

- getFormID() is used to specify the form ID. It isn't used by drupal_get_form() or in validation or submission functions. Although it is used for theme functions, hook_form_alter() etc

- Here is the Drupal 8 version of the form above:

namespace Drupal\form_test;

      use Drupal\Core\Form\FormInterface;

      /**
       * Provides a test form object.
       */
      class FormTest implements FormInterface {

        /**
         * {@inheritdoc}
         */
        public function getFormID() {
          return 'form_test_form_test_object';
        }

        /**
         * {@inheritdoc}
         */
        public function buildForm(array $form, array &$form_state) {
          $form['element'] = array('#markup' => 'The FormTest::buildForm() method was used for this form.');

          $form['test'] = array(
            '#type' => 'textfield',
            '#title' => t('Test'),
          );

          $form['actions']['#type'] = 'actions';
          $form['actions']['submit'] = array(
            '#type' => 'submit',
            '#value' => t('Save'),
          );
          return $form;
        }

        /**
         * {@inheritdoc}
         */
        public function validateForm(array &$form, array &$form_state) {
          drupal_set_message(t('The FormTest::validateForm() method was used for this form.'));
        }

        /**
         * {@inheritdoc}
         */
        public function submitForm(array &$form, array &$form_state) {
          drupal_set_message(t('The FormTest::submitForm() method was used for this form.'));
          Drupal::config('form_test.object')
            ->set('test', $form_state['values']['test'])
            ->save();
        }

      }

- This form would be used in this way: return drupal_get_form('Drupal\form_test\FormTest');

- Form ids for article_node_form is changed to node_article_form. tags_taxonomy_term_form is changed to taxonomy_term_tags_form.

So replace:

if (strpos($form_id, '_node_form') !== FALSE) {

with
      
if (preg_match('#node_(.*?)_form#e', $form_id, $match))

7) variable_get()/variable_set() and variable_del() is removed in Drupal 8:

  • Use the State API to store temporary data. - Use the Configuration API for “deployable” changes (across multiple environments) and use the State API for a specific environment.

8) Info hooks use new Plugin system in Drupal 8:

  • If your module previously defined a hook_something_info(), it now changed to declaring a new class with an "annotation". Specify a specially formatted PHP comments above the class which will provide metadata.
  • Examples in the core are blocks, image styles, text formats, field widgets and formatters, and more.
  • More detail can be found here.

9) New theme system:

  • Drupal 8 theming engine is changed from PHPTemplate to Twig. It is easy to use for themers with better security. It also has clear separation between presentation and logic. Any theme-able output of module should provide a Twig template.
  • Details can be found here.

These are some of the key changes, I stated above. You can find full details of change records here. Search https://drupal.org/list-changes for keywords related to the problem, then follow the instructions there to fix it.

Debugging Techniques

Here are some debugging tips, if you encounter any errors during porting the module:

  1. If your module breaks on installation, Comment out hook_install() and hook_uninstall(). This will turn on your module.
  2. As long as the site is responding, you can use debug() for outputting the result of a variable in Drupal's messages area.
  3. If you're only getting a “white screen of death,” you should check your web server's PHP error log.
  4. Run the rebuild.php script (or drush rebuild). Note: To run the rebuild.php script, you must edit your settings.php file to set $settings['rebuild_access'] = TRUE;

Happy porting..!!!! Need assistance regarding Drupal Website Migration Contact us now!

Nov 23 2016
Nov 23

Tokens provides an input filter that replaces tokens with content. All tokens are binded to its function that returns content as a value for that token. Token can contain parameters that will be passed to its function.

To create custom token, three token api functions are used:

/**
 * Implements hook_token_info().
 */
function MYMODULE_token_info() {
  // Define a new token type.
  $types['custom'] = array(
    'name' => t("Custom Tokens"),
    'description' => t("Tokens that are custom."),
  );


  // Define any new tokens.
  $tokens['fname'] = array(
    'name' => t("First name"),
    'description' => t("First name token"),
  );


  $tokens['lname'] = array(
    'name' => t("Last name"),
    'description' => t("Last name token"),
  );


  return array(
    'types' => $types,
    'tokens' => array(
      'tn' => $tokens,
    ),
  );
}

We are creating custom token type here. Get a list of the existing tokens and types by calling token_get_info() to add token to existing types.

/**
 * Implements hook_tokens(). This hook will operate the token and replace it with it's value.
 */
function MYMODULE_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();


  if ($type == 'custom') {
    // Loop through each of the available tokens.
    foreach ($tokens as $name => $original) {
      // Find our custom tokens by name.
      switch ($name) {
        case 'fname':
          // Work out the value of our token.
          $value = 'Deepali';
          // Give our token it's value!
          $replacements[$original] = $value;
          break
        case 'lname':
          // Work out the value of our token.
          $value = 'Agarwal';
          // Give our token it's value!
          $replacements[$original] = $value;
          break;
      }
    }
  }
  return $replacements;
}

Custom created token will now be available in the list of tokens. You can use Token Insert module to insert tokens into a textarea (plain text and wysiwyg textareas).

ARGUMENTS

You can pass additional contextual data to token_replace() function which is then passed to implementations of hook_tokens(). You can also use below code to pass the values of token dynamically.

/**
 * Implements hook_tokens(). This hook will operate the token and replace it with it's value.
 */
function MYMODULE_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();


  if ($type == 'custom') {
    // Loop through each of the available tokens.
    foreach ($tokens as $name => $original) {
      // Replace token with desired values
      if (array_key_exists($name, $data)) {
        $replacements[$original] = $data[$name];  
      }
    }
  }
  return $replacements;
}


/**
 * Here we will use the token_replace() function to get the actual content after replacement.
 */
function MYMODULE_MYFUNCTION(&$variables) {
  $data = array();
  $data['fname'] = 'Deepali';
  $data['lname'] = 'Agarwal';
  $temp = "Full name : [custom:fname] [custom:lname]";
  $temp = token_replace($temp, $data);
  echo $temp;
  // After token replacement $temp variable will contain "Full name : Deepali Agarwal"
}

The $data parameter can contain either the $user object or the $node object required to calculate the appropriate values.

Feel free to share your valuable inputs/feedbacks. #letstalksolution and need more assistance regarding Drupal Web Development contact us now.

Nov 23 2016
Nov 23

For using basic & common classes for grid layout (For width), typography, alignment etc, we write css like:

For alignment

.margin-top--5px { margin-top: 5px; } .margin-top--10px { margin-top: 10px; } .margin-top--15px { margin-top: 15px; } ...

Typography

.h1-32pt { font-size: 32pt; } .h2-28pt { font-size: 28pt; } .h3-24pt { font-size: 24pt; } .h4-20pt { font-size: 20pt; } ...

Grid views

.width-1 { width: 8.33%; } .width-2 { width: 16.66%; } .width-3 { width: 25%; } .width-4 { width: 33.33%; } ...

  • But with use of below code, all the classes with respective css are generated at once and we don't have to write each css manually.
  • User can generate classes for different properties like width, height, padding, margin, font-size, line-height, etc.
  • Main benefits are any numerical units like px, %, vw, vh, em, rem, etc can be used
  • Whole series of classes like above will be generated by using small code snippet.

Example of generated class with respective value

Ex, width: 10px , width: 15px , width: 20px , … , width: 100px , width: 200px , …

Below code generate CSS properties like:

.margin-top--0per {
  margin-top: 0%;
}
.margin-top--1per {
  margin-top: 1%;
}
.padding-all--0px {
  padding: 0px;
}
.padding-all--10px {
  padding: 10px;
}

Note: Our demo creating 1 to 100 value.

SCSS Code:

/**
 * Adding margin, padding & width classes.
 * Ex. margin-top--10px, padding-all--50per, width--100per
 */


/* Map for position */
$position-map: (
  top: 'top',
  right: 'right',
  left: 'left',
  bottom: 'bottom',
);


$unit-map: (
  per: '%',
  px: 'px',
);


@for $size from 0 through 100 {
  @each $unit, $ut in $unit-map {
    @each $position, $pos in $position-map {
      .margin-#{$position}--#{$size}#{$unit} { margin-#{$position}: #{$size}#{$ut}; }
      .padding-#{$position}--#{$size}#{$unit} { padding-#{$position}: #{$size}#{$ut}; }
    }


    .margin-all--#{$size}#{$unit} { margin: #{$size}#{$ut}; }
    .margin-vertical--#{$size}#{$unit} {
      margin-top: #{$size}#{$ut};
      margin-bottom: #{$size}#{$ut};
    }
    .margin-horizontal--#{$size}#{$unit} {
      margin-right: #{$size}#{$ut};
      margin-left: #{$size}#{$ut};
    }


    .padding-all--#{$size}#{$unit} { padding: #{$size}#{$ut}; }
    .padding-vertical--#{$size}#{$unit} {
      padding-top: #{$size}#{$ut};
      padding-bottom: #{$size}#{$ut};
    }
    .padding-horizontal--#{$size}#{$unit} {
      padding-right: #{$size}#{$ut};
      padding-left: #{$size}#{$ut};
    }


    .width--#{$size}#{$unit} {
      width: #{$size}#{$ut} !important;
    }
  }
}

So, this is a smart code - use it and save your time guys! Feel free to add your views and comments for any Drupal Development Services. #letstalksolution

Pages

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web