Skip to main content

Posts

Showing posts from November, 2019

Events, and Event Subscribers

Drupal 8 provides a powerful and performance efficient way how modules can interact with each other.( I.e we can fire any custom code on a perticular action like, when save configuration of site name etc fire my  custom code etc ) Modules can either dispatch events, subscribe to  events, or both.  Subscribing to an event allows a module to declare that it would like to be  notified anytime a specific event happens. A module can subscribe to any  number of events, and can even subscribe to the same event more than once.   Dispatching an event allows a module, or Drupal core subsystem, to notify any  registered subscribers that a specific event has just taken place. When an  event is dispatched the registered code for each subscriber is executed. For  example, whenever a configuration entity is updated the Configuration API  dispatches a new event allowing all subscribers to react to the change.  Subscribing to an e...

twig templating

Twig is a PHP-based compiled templating language. When your web page renders, the Twig engine takes the template and converts it into a 'compiled' PHP template which is stored in a protected directory in sites/default/files/php/twig. The compilation is done once, template files are cached for reuse and are recompiled on clearing the Twig cache. Preprocessing for Template Files : The main role of the preprocessors is to set up variables to be placed within the template (.tpl.php) or twig files. Every layer in Drupal from core, modules, engines and themes can have numerous preprocessors Mainly There are two main functions to override the  code .. preprocess and preprocess_HOOKS respectly, first is template,module,engine,theme, Most used is theme preprocess and process THEME_preprocess(&$variables,$hook) Where hooks are like menu,page,html, etc THEME_preprocess_HOOK(&$variables) Features of Twig :  Twig Block in Drupal 8 : It is performed by tempelate in...

Cache In Drupal

Drupal 8 core caching modules: The Internal Page Cache module: this caches pages for anonymous users in the database. Pages requested by anonymous users are stored the first time they are requested and then are reused for future visitors. The Internal Dynamic Page Cache module: This is a key feature that Drupal 7 did not have. Unlike the Internal Page module, the Dynamic Page module aims to speed up the site for both anonymous and logged-in users. How Cache Works in Drupal: There are two modules available in the drupal core 1 - Internal page cache: The Internal Page Cache module caches pages for anonymous users in the database. Pages requested by anonymous users are stored the first time they are requested and then are reused. Configuring the internal page cache :   From the performance page we can set the maximum time how long browsers and proxies may cache pages based on the Cache-Control header. 2 - Internal dynamic page cache: Drupal 8 provides the Dynamic Page Cache m...

Apache Solar Search

Apache Solr : -  Apache solr is a fast open-source Java search server. Solr makes it easy to run a full-featured search server Recent version -- Solr 8.11.1 default port: 8983 You can access your Solr admin panel by typing  localhost:8983  in your browser. Basic Solr Concepts:- Solr is able to achieve fast search responses because, instead of searching the text directly, it searches an index instead. Solr is powered by Lucene, a powerful open-source full-text search library, Limitation of default drupal Search:-  1- default drupal search is for smaller sites only, 2- does’t deal with large content like 10k+,  3- Limited operated 4- SQL is not designed as a searching language, 5- It runs and searches directly on the same databases, 6- RDBMS , is incapable to search well, Benefits of using apache solr:-  1- index and make searchable really a large amount of data from 10k up to millions, 2- Provide faceted search-based nav...