Drupalathon’ 17; Happy ending

It was a dream for me to conduct an event in my campus before I graduate (I guess all want something like that in their college life). It all began in late December 2016 where a group of  5 of us(Abhishek, Akash, Chiranjeeb, Prashant and myself) started thinking of a Drupal hackathon- Drupalathon’ 17 in our campus in connection with FOSS@Amrita, to help students get an overview of this powerful Content Management System(CMS) used by many exciting projects including The white house, Harward university, Grammy awards and so on.

We started contacting Drupal communities in and around India for sponsorships. The initial responses weren’t that great. At the same time, we got replies from Jet Brains and GitHub. We assumed it to be sponsorships as funding for the conduct of the event. But, they could only provide the stickers which we could distribute among the participants. Thanks to both these communities.

Months passed, we kept on contacting the local communities, not many responses and in March we could find an exciting update from the Drupal association itself who were ready to share our funding in the form of Community Cultivation Grant(CCG).

At the same time, we were also in talks with the local Drupalers in Bangalore and Trivandrum to find potential speakers who could lead the event. We finally ended up in Rakesh James from Valuebound whom I have met during DrupalCon Asia 2016 in Mumbai. The dates were initially set to March 25 but later on got shifted to April 22nd due to some permission delays.

But, at the last moment, Rakesh had to go to Baltimore to attend the Drupalcon which again brought new issues for us. We were feeling really down that we will lose all of our efforts if we couldn’t implement the plans effectively. To our good luck, Rakesh sorted out the issue by helping us get in touch with Nishant Kumar from his company. That was a huge relaxation for all of us from all the sudden happenings. He also got Chirag Shah, his colleague to help him for the event.

Again when it was nearing the event, April 22nd was declared as a working day,  making us more difficult for the event to occur due to the unavailability of the computer labs, duty leave permissions. We discussed with the speakers and they were kind enough to shift the event to the next day, Sunday, April 23rd.

We had 40 attendees for the event. It got started by 9:3 with Nishant Kumar introducing the participants to an overview of the Drupal ecosystem, its usability, how it stands apart from the current existing technologies. It was a totally interactive one with students raising their questions and clearing their doubts on the various aspects of this technology.


Then Chirag joined Nishant with the installation of Drupal in the local systems. Most of them could install successfully by the lunch time. All were really enjoying the environment learning new things which could come into their real use may be once they start applying it.

IMG_20170423_135233The afternoon session mainly dealt with customizing the website and exploring the various cutting-edge features of this enormous CMS. Students also tried to work out some of them to enjoy the real beauty.

DSC_0298And it was really a happy ending for all of us. We got positive feedbacks from the participants and the speakers. We feel really proud to have conducted the event, breaking all the barriers and ending up a day, sharing the Drupal knowledge with the students of my campus. Thanks to FOSS@Amrita for all the support and encourage throughout entire planning and implementation phase of the hackathon.

Hope we could come up with more events in the future.

GSoC’ 16: Port Search Configuration module; coding week #8

I have been porting Search Configuration module from Drupal 7 to 8 as part of this year’ s Google Summer of Code (GSoC). This summer program is an opportunity for university students to work on projects connected with open source organisation. I have been really lucky to be a part of this initiative. I could explore deep of more technologies, version control systems as part of my project in Drupal. This gives young students a platform where they are assigned mentors who are experts and experienced in various software.

Last week, I could learn some of the Drupal concepts as part of this module port. So, let me begin with the Drupal 7 property. The t function translates a string to the current language or to a given language. This makes the strings used in Drupal translatable. This generally takes up the format:

t($string, array $args = array(), array $options = array());

Here, $string is the string containing the English text to get translated.

$args: An associative array of replacements to make after translation.

$options: An optional associative array of additional options, with the following elements: lang code and context.

This t function has got some alteration in the Drupal 8. It has been replaced by the $this->t() by making use of \Drupal\Core\StringTranslation\StringTranslationTrait. 

 The translatable markup returns a string as a result of this process.

Another important aspect which I dealt was the roles. This is an important feature  for any module as it  deals with the security constraints of the module. Roles are often manipulated to grant certain permissions. What we have to do is that, initially, load the particular role to be manipulated and then provide the permission which is to be granted.

$role = Role::load('access page.');
$role->grantPermission('access comments');

These role functions help us to load the roles and manipulate the permissions assigned to it quite easily. Thus, turns out to be really helpful in dealing with permissions.

I have been also dealing with writing the simple test for my module. In one of my previous blog posts, I have introduced the PHP unit testing.  The simple test tests the web oriented functionality of the module. It needs a good understanding of the behaviour of the module to write an effective test. Tests are often really important to identify the flaws of a functionality and to correct it accordingly. I will be writing the simple tests for my module in the coming days. I will be sharing you the concept of this mode of testing in my next blog post.

Stay tuned for further developments on this blog post.




GSoC’ 16: Port Search Configuration module; coding week #6

Google Summer of Code (GSoC) is into the next phase of coding after the mid-Term evaluations which got over by June 27th. This also reminds students to speed up the coding activities to complete the projects within the schedules provided in the proposal.

I am porting Search Configuration module to Drupal 8 as part of this year’s summer of code. GSoC is definitely turning out to be a venue for the young students from universities around the world to work on real-world projects under the experience of well-known developers, learning new technologies, making use of version control systems, with regular meetings and finally building up a software which is going to help a large section of the society.

I blog regularly, sharing my project progress. If you would like to have a glimpse of my past activities on this port, please visit this link.

Drupal 8 has introduced the concept of Html twigs in place of the PHP templates. So, the PHP template files have to be now ported to the Html environment. The .tpl.php template file is replaced by the .html.twig file for the module templates.  Templates are simply text files which can give outputs in Html, Latex, CSV or XML formats.

To print some data, we usually take the service of echo statements in PHP.  The print statements are replaced by {{ }} in Html twigs.

<?php echo t(‘Let’s start the process.’); ?>

is replaced by:

{{ ‘Le’s start the process’|t }}

The variable names have to be converted to simple names. For instance,



{{  title }}

The PHP logics have to be replaced by {% %} syntax. This is applicable to all the logical statements.

<?php if ($page[‘title]): ?>


<?php endif; ?>

is transformed as:

{% if form %}


{% endif %}

Also, the variables are replaced by simple names.

<?php if ($logo): ?>

is transformed as:

{% if logo %}

These were some of the basic transformations to get started into created the HTML twigs.The use of the Html twigs has made the templates look very simple and easily understandable. It is really easy to get the templates converted to the Html twigs. This is always one of the crucial requirements of porting modules from Drupal 7 to Drupal 8.

Stay tuned for further updates on this port process.

GSoC’ 16: Port Search Configuration Module to Drupal 8 : Mid Terms

I feel really excited to have cleared the mid-Term requirement for my project in Google Summer of Code (GSoC). The results of the mid-Term evaluations were announced June 28, 00:30 IST. This was the evaluation for the first phase of GSoC. In this evaluation process, set up by GSoC organisers, students and mentors have to share their feedback about the current progress of the project. Mentors need to give a pass/ fail grade. Students can continue coding once they clear the evaluations successfully.

I have been working on Porting Search Configuration module to Drupal 8. Please go through my previous posts if you would like to have a look into the past activities in this port process.

Last week I worked on testing some of the units of this module using the Php unit tests framework. Testing is an important process when it comes to any software development process. It plays a crucial role for any software. It helps us to understand the improve our software to the required level by making use of various test cases. We input various values and check whether the tests are passed according to the requirement. If any condition fails to our expectations, we need to make the required changes to suit the application needs.

Php unit tests are generally used to test some units of an application. To check whether the functions implemented gives the expected output, behaviour of the functions in various test cases, giving different types of arguments as inputs to check the errors or flaws for improving the application.

We need to install the Php unit for this process. You could follow this documentation for this process. Furthermore, they give a detailed analysis of the Php Unit Tests.

Once the installation is completed, we can start writing the unit tests for the functionalities we have implemented. The tests are generally stored in the tests/src/Unit directory of the module. The name of the unit test file will be of the format xyzTest.php. All tests are suffixed by ‘Test’. ‘xyz’ can be replaced by the functionality you are going to test.

The following is a simple test to check the sum of two numbers: sumTest.php

class SampleTest extends PHPUnit_Framework_TestCase
  public function testSum()
    $this->assertEquals(2+2, 4);

As mentioned in this above code snippet, we need to create a class, with class name suffixed by ‘Test’ which is an extension of PHPUnit_Framework_TestCase. Now, we need to write the tests inside as member functions. The functions starting with the name test are executed. Here we are checking the sum of the two numbers. This is a very simple demonstration.

The tests are run by using the command PHPUnit. i.e,

$ phpunit tests/src/Unit/sumTest.php

The output generated on running the above test is:

PHPUnit 5.4.6 by Sebastian Bergmann and contributors.

. 1 / 1 (100%)

Time: 252 ms, Memory: 13.25MB

OK (1 test, 1 assertion)

Stay tuned for future updates on this module port.


GSoC’ 16: Port Search Configuration module; coding week #4

Google Summer of Code (GSoC), has entered into the mid-Term evaluation stage. This is a 1 week period from 21- 27 June, were students and mentors present the progress of their projects. Based on the reports submitted, students are made pass/ fail.

I have been working on porting Search Configuration to Drupal 8 in the past few weeks. If you would like to have a quick glimpse of my past activities on this port process, please go through these posts.

last week, I could learn some Drupal concepts which were really helpful for my project. In the previous versions of Drupal, the role permissions were stored in a role_permissions table in the Database. But now, in Drupal 8, the role permissions are directly stored in the role configuration entity.

So, as described above, in D7 and its preceding versions, role permissions were stored in a role_permissions database which had the role Id and the corresponding permissions. The permissions distributed to a role was retrieved in D7 using:

$permissions = role->getPermissions();

But, in D8, this is done by the

$permissions = role->getPermissions();

Another instance is that, to grant certain permissions to roles.

In D7 it was controlled by,

user_role_grant_permissions($rid, array(‘ access content’));

The role configuration entity remodels this functionality in D8 to:

$role->grantPermission(‘ access content’);

In connection with the term permissions, the most important aspect in Drupal is a hook: hook_permissions(). This hook, obviously as you might have guessed, distributes the permissions to various users; decides whether a particular user should be allowed to access a page or a content, granting and restricting the access.

This hook has been replaced in Drupal 8 by a module.permissions.yml file. This file contains the permissions and its specifications. We can write a driver function in a php file to add the dynamic permissions. This can be achieved by making a driver class in the php file and adding the behaviour of the permission we need in the member functions of the class. We also have to link this PHP file with our yml file to keep it active. This is done by adding a callback function in the yml file which references this php file.

To display special characters in a plain text string for display as HTML format, Drupal earlier versions used the function check_plain.  This had the general syntax:

check_plain($text); // where $text was the string to be processed.

This function has got deprecated in Drupal 8. This has been replaced by the \Drupal\Compoent\Utility\Html::escape($text).

I will be back next week with further updates on this port process.


GSoC’ 16 community bonding with Drupal

I have been selected for the Google summer of Code’ 16 for Drupal for the project, Port search configuration module to Drupal 8. Thanks to all the developers in #Drupal IRC channel for guiding me into this summer project by sharing their ideas and suggestions.

The search configuration feature is presently available in Drupal 7 and its preceding versions. This is really a cool feature which helps us a lot in improving the search and enhancing it for better search results. This summer, I will be engaged in porting this module to Drupal 8.

The GSoC projects were announced on April 22, 2016. All selected students have a community bonding period till May 22nd. This is the time when students get closer to the organisation, learn the organisation code base, interact with mentors, plan more about the project and its deadline for the coding period which starts soon  after this community bonding.

I have been blessed with three experienced mentors from Drupal- Naveen Valecha, Neetu Morwani and Karthik Kumar. I have been discussing with them regarding the project plan for the last few weeks. Meanwhile, I was also asked to learn some of the basic concepts of Drupal like hooks, hook permissions, forms in Drupal which are the real components of my project. This helped me a lot to understand more about the coding methodologies I need to adopt.  I could go through the code base of the module in Drupal 7 which has helped me collect more ideas for the project.

I also got the opportunity to hack with some simple modules by creating a sandbox project in Drupal and pushing commits on sample module developments I did to learn the basics of the module. I have created a project in Drupal for the search configuration port and has added the tasks I need to complete in association with this process.

I  will be posting regular updates regarding my GSoC project here.

Best of luck to all the selected students.

Looking for a bright summer ahead, coding for Drupal.

Thank you.

Google Intern!

Finally, got selected for the prestigious google summer of code 2016 (GSoC’ 16). GSoC is a yearly summer internship program conducted by Google in connection with open source organizations where students get an opportunity to work on projects under an experienced panel of mentors.

Congrats to all those who have attempted for this selection process. The proposal writing itself is a wonderful experience where we could work with many high profile people, discussing a lot about the possible implementation patterns of various projects.

This was the first time I was applying for this program and luckily by god’s grace, everything clicked well and I am into the final list of selected members for this year’s GSoC. So, I will be coding for Drupal, on the project, ‘Port Search Configuration Module to Drupal 8’. I am mentored by Naveen Valecha, Neetu Morwani and Karthik Kumar.

April 2016 was really a lucky month for me. Apart from this internship, my team ended up as runner ups in the Amrita Super Minds Quiz finals. I also got one of my article published on contributing to Drupal in the upcoming edition of Open Source For You, Asia magazine.

Hoping to have a nice summer ahead.