Skip to main content

GSoC'19 Coding Period | Week #6 | Icon API

The Google Summer of Code has reached the end of the week #6 of the coding period with my project "Complete porting of Icons API to Drupal 8" being progressing smoothly with interesting challenges along the way.

In my previous blog post, I had mentioned that I'll be implementing the part where the icon is displayed in the menu link title as saved through the configuration page of the menu link.

During this week, I've successfully implemented what I've mentioned in my previous blog and the icons are displaying on the menu link title and this was achieved using the template_preprocess_menu() hook and plugin id for the menu link is stored in the following tree path of the array:

$plugin_id = $variables['items'][index]['original_link']->getPluginId();

The following code snippet of the function is responsible for displaying the code on the menu link item:
function _icon_menu_get_icon_tag($tag, $icon, $classes, $title, $position, $title_wrapper, $title_wrapper_element, $title_classes) {
  $markup = '<' . $tag . ' class="fa fa-' . $icon . ' ' . $classes . '"></' . $tag . '>';
  if ($title_wrapper) {
    $title = '<' . $title_wrapper_element . ' ' . (!empty($title_classes) ? 'class="' . $title_classes . '"' : '') . '> ' . $title . '</' . $title_wrapper_element . '>';
  switch ($position) {
    case 'title_before':
      $markup .= $title;
    case 'title_after':
      $markup = $title . $markup;
    case 'title_invisible':
      $markup .= '' . $title . '';
    case 'title_replace':
      $markup = $markup . '';
  return Markup::create($markup);
The following screenshot shows the configuration form of the Home menu link item:
 The following screenshot shows the home page with the icon displayed as saved through the configuration:

The challenge faced during this week was to fetch the plugin id of the menu link by looking at the tree of the key/value pairs using the Devel module and find the pattern in the tree and check the plugin id against the list of plugin ids saved from the configuration form.

For the next week, I'll be implementing the Icon Filter module using the Filter API and processing the result using the regular expression to detect the pattern and replace the occurrence of the pattern with the icon.


Popular posts from this blog

GSoC'19 Coding Period | Week #3 | Icon API

The Google Summer of Code has reached the end of the week #3 of the coding period with my project " Complete porting of Icons API to Drupal 8 " being progressing smoothly with interesting challenges along the way. In my previous blog post , I had mentioned that I'll be working on implementing the Autocomplete controller class which will display the icons list based on the search keyword provided by the query string and Font Awesome Icon data class which is responsible for parsing and caching the icon data from the icons.yml file provided by the fontawesome icon library. During this week I've implemented the Icon data class called  FontAwesomeIconData class with two functions/methods which are getIconArray() and determinePrefix().  The determinePrefix() function takes the style of icon as a parameter and determines the prefix to be used for that icon. For instance, if the icon style contains brands then it returns ' fab ' otherwise it returns 

GSoC'19 Coding Period | Week #1 | Icon API

The Coding phase of Google Summer of Code 2019 commenced in the last week on May 27, which marks the end of the Community bonding period. As stated in my previous post , the community bonding period gives the students an opportunity to build affinity with the community and learn more about the project and the organization. Currently, I am working on porting Icon API module to Drupal 8, under the guidance of Chiranjeeb Mahanta , which integrates the Icons into the Blocks, Menu Items, Fields and the content using the shortcodes and it makes the website look beautiful by using the right Icon at the right place. For the first phase/month of the coding period I plan to port the following features: Learnt how to implement the Plugin API which will allow the new Icons bundles to be integrated into the main module and the Icon bundles can accessed from any of the sub-modules. To understand the plugin system the article which helped me understand it is " Unraveling the Drupal 8

Community Bonding with Drupal | GSoC'19

This year I got selected into Google Summer of Code (GSoC'19) under Drupal for the project " Complete porting of Icon API to Drupal 8 ". The Icon API is a module which integrates the icons throughout the drupal site. This blog post focuses on Community bonding period with Drupal for GSoC'19. This year, accepted proposals/projects were announced on May 6, 23:30 IST. The selected students are supposed to participate in the Community bonding before the coding phase actually begins. The coding phase starts from May 27 and ends on August 26 with three project evaluations. The Community bonding period is almost a month long and the students are supposed to contact their mentors to discuss the project, learn more about the organisation's they are contributing to, learn the essentials APIs or technologies required to complete the project. I contacted my mentor Chiranjeeb Mahanta who was the GSoC'17 student worked on the project Porting Wish list module to Drupa