Skip to main content

Posts

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

Recent posts

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

The  Google Summer of Code  has reached the end of the week #11 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'd be fixing the autocomplete issue with the Icon Field module and looking for any bugs in the whole project. During this week, I've implemented the autocomplete update thing in the Icon Field module and the following code is called when there is a change in the select field using the ajax: /** * * Returns the 'Search icon' textfield */ public function updateIconField(array &$form, FormStateInterface $form_state) { // Get the delta $delta = $form['#icon_field_delta']; // Get the field name $field_name = $form['#icon_field_name']; $icon_form = $form[$field_name]['widget']['' . $delta . '']['icon']; // Get the

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

The Google Summer of Code has reached the end of the week #10 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 finishing the Icon Field submodule and checking the whole project code to find the potential bugs or future errors. During this week, I've implemented the Field Formatter and wrote a twig template to render the icon which was defined using the hook_theme() in the icon_field.module file. The twig template(defined in templates/icon-field.html.twig ) to render the icons is as follows: {# Icon Field Twig template for displaying the icon #} {% if link is not empty %} <a href="{{ link }}"> {% endif %} <{{ wrapper }} class="fa fa-{{ icon }} {{ wrapper_classes|join(' ') }}"></{{ wrapper }}> {% if link is not empty %} </a> {% endif %} In th

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

The Google Summer of Code has reached the end of the week #9 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 Icon Field sub-module using the Field API with the Field Type, Field Widget and Field Formatter which will allow the users to specify the icon for the content type. During this week, I've implemented the Field Type, Field Widget and Field Formatter using the Plugin API and Annotations. The annotation for the Field Type which resides in the src\Plugin\Field\FieldType\IconFieldItem.php is as follows: /** * Plugin Implementation of the 'icon_field' field type. * @FieldType( * id = "icon_field", * label = @Translation("Icon Field"), * module = "icon_field", * description = @Translation("Store a bundle and icon in the database t

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

The Google Summer of Code has reached the end of the week #8 which marks the end of the two month 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 refactoring the code for the Icon Block which was implemented during the application period of the GSoC but there was a lot of hardcoding and it had no option to select the icon bundle and for this week I've refactored the code of the Icon Block module and made it compatible with the Icon API and Font Awesome Bundle. During this week, I've removed some hardcode from the Icon Block sub-module like importing the fixed libraries and fetching the icon data from that library. The Icon Block module was made to get the icon bundle list and update the search form with the selected autocomplete_route_name using the ajax. The following code snippet fetches the I

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

The Google Summer of Code has reached the end of the week #7 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 Icon Filter sub-module which will find and replace the pattern with the icon. The module replaces the following pattern with the icon: [icon:%bundle:%icon] where %bundle = Icon bundle machine name and             %icon = Icon name in the icon bundle During this week, I've searched on Google for implementing the Filter API in Drupal 8 and then I found Creating a Custom Filter in Drupal 8 article on lullabot.com which helped me in understanding and implementing the Icon Filter sub-module. In the Drupal 7 version of Icon Filter module was developed using the hooks but in the Drupal 8 it was replaced with the Plugin system which resides in the src/Plugin/Filter directory

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, $tit