Drupal http://purushotam.in/ en Accessing Translated Entity in Views Twig | Drupal 8 http://purushotam.in/notes/accessing-translated-entity-views-twig-drupal-8 <span property="schema:name">Accessing Translated Entity in Views Twig | Drupal 8</span> <span rel="schema:author"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">purushotam</span></span> <span property="schema:dateCreated" content="2021-07-12T23:49:18+00:00">Tue, 07/13/2021 - 01:49</span> <div property="schema:text" class="text-content field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Though ideally if we use the views correctly and override them well, Drupal Views itself take care of getting the translated version as per configurations of the view. For details check this: <a href="https://api.drupal.org/api/drupal/core%21modules%21views%21src%21Plugin%21views%21field%21EntityField.php/function/EntityField%3A%3AgetValue/8.8.x">EntityField::getValue</a></p> <p>But if somehow we wanna get translated version of the entity in a views twig, we will have to get the current language and then call <a href="https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21ContentEntityBase.php/function/ContentEntityBase%3A%3AgetTranslation/8.8.x">ContentEntityBase::getTranslation</a> on the entity of the views row. And there are various ways of getting the current language in the views-view.html.twig:</p> <p>#1 Use preprocess to add current language</p></div> Mon, 12 Jul 2021 23:49:18 +0000 purushotam 50 at http://purushotam.in Storing extra information for any entity in Drupal http://purushotam.in/articles/storing-extra-information-any-entity-drupal <span property="schema:name">Storing extra information for any entity in Drupal</span> <span rel="schema:author"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">purushotam</span></span> <span property="schema:dateCreated" content="2021-04-03T21:20:04+00:00">Sat, 04/03/2021 - 23:20</span> <div property="schema:text" class="text-content field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>A lot of times we come across a requirement where we need to manage some additional data for the Drupal entities. Now, if we think simply, the solution is to create fields .. right... easy and best, that's what Drupal is all about, entities and their properties as fields. But, there can be scenarios where the entity is not fieldable (as of now).</p> <p>We will be specifically focusing on them in this post, though this can be implemented for any entity, the key is to understand what we want to solve and how, it's a kind of trade-off that we need to do while making any decision. As I always say Drupal has a lot of ways to solve a problem statement, it's you who decide which is the efficient one. You may not find the below solution as most efficient or scalable for you, but definitely, you would draw some important knowledge/information from this post.</p></div> Sat, 03 Apr 2021 21:20:04 +0000 purushotam 49 at http://purushotam.in Making a variable available (as global) in all twig files in Drupal http://purushotam.in/notes/making-variable-available-global-all-twig-files-drupal <span property="schema:name">Making a variable available (as global) in all twig files in Drupal</span> <span rel="schema:author"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">purushotam</span></span> <span property="schema:dateCreated" content="2021-03-30T23:28:39+00:00">Wed, 03/31/2021 - 01:28</span> <div property="schema:text" class="text-content field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Most of us know, the ideal way of making a variable available in a specific twig file is to use hook_preprocess_HOOK. But what if we have a requirement that we need a kind of global variable that should be accessible in any twig file. So, that we are able to use it wherever we want to, without additional pain.</p> <p>The best part of Drupal is, everything is possible. But at the same time, there is a trick, you always have more than one way of doing things. And now it's in your hands to pick up the best suitable performant way for your solution.</p> <p>So, over here you have the following solutions (which I can instantly think for this problem statement):</p></div> Tue, 30 Mar 2021 23:28:39 +0000 purushotam 48 at http://purushotam.in How to check if Memcache, opcache or varnish is functional with the Drupal 8 application? http://purushotam.in/reposts/how-check-if-memcache-opcache-or-varnish-functional-drupal-8-application <span property="schema:name">How to check if Memcache, opcache or varnish is functional with the Drupal 8 application?</span> <span rel="schema:author"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">purushotam</span></span> <span property="schema:dateCreated" content="2021-02-27T23:01:22+00:00">Sun, 02/28/2021 - 00:01</span> <div property="schema:text" class="text-content field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>A successful application is always defined by its performance and Security besides the proper operational functioning. Drupal 8 can make use of Memcache, opcache and varnish to significantly reduce the load on the servers and greatly improve the performance. After installing and setting up these performance improvement tools it’s important to know if they are actually working and improving the application performance. Let’s explore the validation ways for each of them:</p></div> Sat, 27 Feb 2021 23:01:22 +0000 purushotam 21 at http://purushotam.in Acquia Backend Specialist Certification Guide http://purushotam.in/articles/acquia-backend-specialist-certification-guide <span property="schema:name">Acquia Backend Specialist Certification Guide</span> <span rel="schema:author"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">purushotam</span></span> <span property="schema:dateCreated" content="2021-02-27T21:49:22+00:00">Sat, 02/27/2021 - 22:49</span> <div property="schema:text" class="text-content field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Recently completed Acquia Backend Specialist Certification thought to share my thoughts around this certification exam that might help the aspiring ones. While preparing for this exam, I had heard that this is the toughest exam out of all the Acquia Drupal Certifications and in my opinion, this rumour is true.</p> <p>Actually, these certifications might be easy for others but were not for me, as, since last 1.5 yrs I have been working in Drupal 7 only. When I started preparing for this exam, I followed the same preparation pattern which I used while preparing for Acquia Drupal 8 Developer Certification Exam.</p></div> Sat, 27 Feb 2021 21:49:22 +0000 purushotam 6 at http://purushotam.in Events - Object Oriented Version of Hooks | Speaker | Drupal Camp Pune 2017 http://purushotam.in/stories/events-object-oriented-version-hooks-speaker-drupal-camp-pune-2017 <span property="schema:name">Events - Object Oriented Version of Hooks | Speaker | Drupal Camp Pune 2017</span> <span rel="schema:author"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">purushotam</span></span> <span property="schema:dateCreated" content="2021-02-27T22:34:00+00:00">Sat, 02/27/2021 - 23:34</span> <div property="schema:text" class="text-content field field--name-body field--type-text-with-summary field--label-hidden field__item"><h1 dir="ltr"><b id="docs-internal-guid-299f0533-c463-a9b4-9d41-50ea1a462af1">Overview</b></h1> <p dir="ltr">Drupal 8 uses events to allow modules and various subsystems to communicate with one another in an object-oriented manner. Understanding how the Event API works is critical knowledge for all module developers.</p> <h2 dir="ltr"><b id="docs-internal-guid-299f0533-c463-a9b4-9d41-50ea1a462af1"><img alt="Drupal 8 Events" data-entity-type="file" data-entity-uuid="2596667c-5139-49e0-a22c-00f8ab8c8a09" height="284" src="/sites/default/files/inline-images/drupal_8.png" width="226" class="align-right" loading="lazy" />Agenda</b></h2> <ul> <li dir="ltr"> <p dir="ltr"><b id="docs-internal-guid-299f0533-c463-a9b4-9d41-50ea1a462af1">Understand Drupal Events versus Hooks</b></p></li></ul></div> Sat, 27 Feb 2021 22:34:00 +0000 purushotam 33 at http://purushotam.in http://purushotam.in/stories/events-object-oriented-version-hooks-speaker-drupal-camp-pune-2017#comments Speaker | Global Training Day | SICSR Pune | 2016 http://purushotam.in/stories/speaker-global-training-day-sicsr-pune-2016 <span property="schema:name">Speaker | Global Training Day | SICSR Pune | 2016</span> <span rel="schema:author"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">purushotam</span></span> <span property="schema:dateCreated" content="2021-02-27T22:30:45+00:00">Sat, 02/27/2021 - 23:30</span> <div property="schema:text" class="text-content field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Drupal Global Training Days is an exciting initiative from the Drupal community to introduce new and beginning users to Drupal</p> <p>This Training was centered around OPEN SOURCE : Drupal 8 Content Management System . For reference and proper understanding of the trainees, the training was based on Online Profile/CV (website) Building using Drupal 8. </p> <p>Around 80+ Students attended this session.</p></div> Sat, 27 Feb 2021 22:30:45 +0000 purushotam 32 at http://purushotam.in http://purushotam.in/stories/speaker-global-training-day-sicsr-pune-2016#comments Acquia Front-End Specialist Exam Preparation Pointers http://purushotam.in/notes/acquia-front-end-specialist-exam-preparation-pointers <span property="schema:name">Acquia Front-End Specialist Exam Preparation Pointers</span> <span rel="schema:author"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">purushotam</span></span> <span property="schema:dateCreated" content="2021-02-27T22:21:49+00:00">Sat, 02/27/2021 - 23:21</span> <div property="schema:text" class="text-content field field--name-body field--type-text-with-summary field--label-hidden field__item"><p> </p></div> Sat, 27 Feb 2021 22:21:49 +0000 purushotam 27 at http://purushotam.in http://purushotam.in/notes/acquia-front-end-specialist-exam-preparation-pointers#comments PHP function in twig - EASY! Ever tried TWIG in PHP function? http://purushotam.in/notes/php-function-twig-easy-ever-tried-twig-php-function <span property="schema:name">PHP function in twig - EASY! Ever tried TWIG in PHP function?</span> <span rel="schema:author"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">purushotam</span></span> <span property="schema:dateCreated" content="2021-02-27T22:20:56+00:00">Sat, 02/27/2021 - 23:20</span> <div property="schema:text" class="text-content field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>I was working on issue queue of <a href="https://www.drupal.org/project/views_extras">views extras</a> module and came across a requirement: Add twig support: <a href="https://www.drupal.org/project/views_extras/issues/2948514">https://www.drupal.org/project/views_extras/issues/2948514</a>. For a moment I was helpless, I mean I always had the requirement to use PHP function in twig but never thought in the reverse direction and to resolve that issue I need to know how we can support twig variables in PHP.</p> <p>Now, <em>this was interesting</em>, so I began my search with finding out how Drupal handles output using twig how it replaces variables and all. I went into the code to find that but soon I changed my mind and found the solution another way.</p></div> Sat, 27 Feb 2021 22:20:56 +0000 purushotam 26 at http://purushotam.in http://purushotam.in/notes/php-function-twig-easy-ever-tried-twig-php-function#comments Lets override Drupal services (with and without overriding arguments) | Drupal 8 http://purushotam.in/notes/lets-override-drupal-services-and-without-overriding-arguments-drupal-8 <span property="schema:name">Lets override Drupal services (with and without overriding arguments) | Drupal 8</span> <span rel="schema:author"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">purushotam</span></span> <span property="schema:dateCreated" content="2021-02-27T22:19:35+00:00">Sat, 02/27/2021 - 23:19</span> <div property="schema:text" class="text-content field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Service-based architecture is one of the major strength of Drupal 8. Drupal core and contrib provide lots of services to be used by other services, plugins or any other function. The flexible nature of Drupal allows overriding of services.</p> <p>We can have different scenarios:</p> <ol> <li><strong>Override Drupal Service without overriding arguments</strong></li> <li><strong>Override Drupal Service, overriding arguments as well</strong></li> </ol> <p>Now, both of them can be resolved using the approach discussed in <a href="https://www.drupal.org/docs/8/api/services-and-dependency-injection/altering-existing-services-providing-dynamic-services">https://www.drupal.org/docs/8/api/services-and-dependency-injection/altering-existing-services-providing-dynamic-services</a> where we implement a class extending ServiceProviderBase and the alter() method.</p></div> Sat, 27 Feb 2021 22:19:35 +0000 purushotam 25 at http://purushotam.in http://purushotam.in/notes/lets-override-drupal-services-and-without-overriding-arguments-drupal-8#comments