Home
A blog about web development and Drupal.

api

August 1, 2016

Slack Chat: Chatting with Visitors on a Drupal Site

Since we switched to Slack as the primary means of communication at work, Slack has grown to be my favorite chat application. Not only does it have a very pleasant interface, but it also offers great ways to integrate it with your application. As a matter of fact, their API is among the least restrictive ones in my experience. As a result of the joy of working the Slack API, Slack chat module was born to serve as a proof of concept for embedded Drupal-to-Slack chat functionality. Using Slack chat module, you can add a chat widget to your Drupal site that your visitors can use to chat with…

June 28, 2016

Extending Drupal's Node.js Integration

The Node.js integration Drupal module offers an API that allows developers to add real-time push notification functionality to their modules. Real-time communication could enable features like chat, pop-up notifications, or real-time content update. Chatroom is a great example of how a module can leverage Node.js. What does Node.js integration do? When a visitor opens a page on which the Node.js module is enabled, the client-side JavaScript opens a socket connection between the visitor's browser and the Node.js server. The Node.js server runs the drupal-nodejs application that communicates…

February 9, 2016

Drupal 8 Cheatsheet for Developers

It has been a few months since Drupal 8 was released and sites built with it are starting to crop up. I myself have had the pleasure of working with it, and more Drupal 8 projects are certainly on the horizon. From a developer's perspective, this version is substantially different from the previous one, and we will need to learn a handful of new ways of doing things. To ease the process, I have put together this list of how-tos with tasks that I commonly encounter during development. I hope you will find it helpful. Generating URLs In Drupal 7, its path was the definitive way to retrieve a…

November 23, 2015

Where is hook_page_alter in Drupal 8?

In Drupal 7, hook\page\alter was a convenient way to go when we needed to modify page elements that were added by other modules. Drupal 8 does away with this hook - hopefully for the better. To fill the void created by hook\page\alter’s dismissal, the following hooks have been introduced. - hook\page\attachments() - hook\page\attachments\alter() - hook\page\top() - hook\page\bottom() - hook\theme\suggestions\HOOK() - hook\theme\suggestions\HOOK\alter() In addition, we can still implement hook\preprocess\page, which does let us override or add content to the page. However, this hook is…

October 2, 2015

Offering Configuration Options for a Custom Views Plugin in Drupal 8


In the previous post, we discussed how to write a style plugin for Views in Drupal 8. In this post, we will see how to allow the user to configure our style plugin. We had previously created a class named CardsStyle for the plugin. In order to add configuration options, we will need to extend that class with two new method: buildOptionsForm and defineOptions as follows. In buildOptionsForm, we add our options to the configuration form - in this case, the only option will be to specify the padding in the card items. This works just like a form callback; we can add our fields to the $form array…