Blogs on

Drupal planet

knackforge blog

Programmatically create and trigger feeds importer

We met with a challenging requirement where we needed to create a feeds importer on node creation of particular content type. It’s like for ‘n’ number of nodes there must be a ‘n’ number of feeds importer.

For that I created a feeds importer which will be considered as the template. Whenever the node of specific content type is created, the template will be cloned and a new importer will be created.

The following code needs to reside in hook_node_insert() and will be used to clone the feeds importer:

Continue reading →
knackforge blog

CDN Module, and Amazon Cloudfront in Drupal 7

Recently I decided to check out Amazon CloudFront to use it as a CDN. I felt delighted as it was so easy to setup with drupal and configuring it involving just a few steps. Another thing that excited me was its cost. It is really really cheap, just costs about 12 cents per gigabyte of transfer.

Step 1: Create a CloudFront Web Distribution

     To create a CloudFront web distribution

Continue reading →
knackforge blog

Drupal moodle integration

We got an interesting requirement, to integrate Drupal and Moodle (Totara actually) in order for a nice combination of CMS features and LMS features. The integration should follow SSO, where a user logged in Drupal should automatically be logged in Moodle.

We decided to use existing plugins as much as possible along with additional customization wherever needed.

Continue reading →
knackforge blog

Disable Drupal 8 cache during development

We know Drupal 8 has a heavy caching mechanism, so we need to clear cache for changes made in twig file or some other file to reflect in the site. Basically, a themer or developer won't love the caching system on the development stage. So it is better to disable cache on the development stage rather than clearing cache for every change being made.

And here are the steps to disable cache and save your valuable time:

  • Copy and rename the sites/example.settings.local.php file as sites/default/settings.local.php

Continue reading →
knackforge blog

How to manually update Drupal 8 core?

Let's see how to update your Drupal site between 8.x.x minor and patch versions. For example, from 8.1.2 to 8.1.3, or from 8.3.5 to 8.4.0. I hope this will help you.

  • If you are upgrading to Drupal version x.y.z

           x -> is known as the major version number

           y -> is known as the minor version number

           z -> is known as the patch version number.

Continue reading →
knackforge blog

Formatting the way the date/time is displayed in Drupal 8

You can create a new date/time format by navigating to Admin -> Configuration -> Regional and Language -> Date and Time format and click on 'Add Format'. Once you’ve created date format, you can control the way date is displayed on the node using preprocess function.

In theme_name.theme file, add the following lines. This would override the way date is displayed in node.

Continue reading →
knackforge blog

Drupal 8 block caching

The approach to custom block caching is different in Drupal 8 from Drupal 7. In Drupal 8, all renderable arrays are cacheable, even those returned by custom block.

Examples:

  • Some expensive-to-calculate data depends on the active theme: different results for different themes. Then you'd vary by the theme cache context.

Continue reading →