Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough
Oct 04 2020
Oct 04

Retrieving the image URL from an image field in Drupal 8 and 9 seemed pretty straightforward too. Even the solution for getting the image style URL from a simple image field can be found quite easily. Getting the image URL from a media field can also be looked up easily.

In case, if an image displays as a media with display mode:

{% if content.field_media|field_value is not empty %}
  {% set image_url = file_url(content.field_media[0]['#item'].entity.uri.value|image_style('inline_media')) %}
  {% set image_title = content.field_media[0]['#item'].title %}
  {% set image_alt = content.field_media[0]['#item'].alt %}
  {% if image_url %}
    
  {% endif %}
{% endif %}

In case, if an image displays as a thumbnail:

{% if content.field_media|field_value is not empty %}
  {% set file_url = file_url(content.field_media['#object'].field_image.entity.uri.value|image_style('inline_media')) %}
  {% set file_alt = content.field_media['#object'].field_image.alt %}
  {% set file_title = content.field_media['#object'].field_image.title %}
  {% if image_url %}
    
  {% endif %}
{% endif %}
Apr 13 2020
Apr 13

The "Update Manager Advanced" module very similar to "Update Status Detailed Email", however, implemented in another way and available for Drupal 8 and 9.

This module modifies the Drupal "Available updates" email report to include the information normally shown at /admin/reports/updates/update, with links to the module updates and their release notes.

It can be helpful, for example, in case, if you received the mail and see that only one module was updated and this module uses on the admin interface only and nothing critical for the visitors and updating can wait. So you shouldn't spend time in opening the site for checking.

Link to the module: https://www.drupal.org/project/advupdate.

Apr 13 2020
Apr 13

Since starting from Drupal v8.8.0 has removed the Wikimedia merge plugin and replaced it with a Composer 'path' repository, a native Composer feature which serves the same needs as the merge plugin with fewer disadvantages, in this short article, I want to show how to manage dependencies for a custom project.

Create composer.json file with a similar code:

{
    "name": "mypackage/custom_module",
    "description": "The description of my module.",
    "type": "drupal-custom-module",
    "homepage": "https://makedrupaleasy.com",
    "authors": [
        {
            "name": "Ruslan P",
            "homepage": "https://www.drupal.org/u/ruslanp",
            "role": "Maintainer"
        },
    ],
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "preferred-install": "dist"
    },
    "require": {
        "symfony/dom-crawler": "^4.0",
        "symfony/css-selector": "^4.0"
    }
}

Find the repositories section of your root composer.json file, and modify it to include your custom module or modules as path repositories:

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    },
    {
        "type": "path",
        "url": "docroot/modules/custom/custom_module"
    }
]

Next, require your module in your project: composer require mypackage/custom_module

Done!

Related links:

Mar 30 2020
Mar 30

PHP/WEB Developer / Drupal Expert. More than 11 years of experience delivering Drupal based General Purpose solutions for different sectors such as Job Boards, Product Portfolios, Geo Coding, Real Estate solutions, E-Commerce, Classifieds, Corporate and online Magazines/Newspapers.

Mar 25 2020
Mar 25

PHP/WEB Developer / Drupal Expert. More than 11 years of experience delivering Drupal based General Purpose solutions for different sectors such as Job Boards, Product Portfolios, Geo Coding, Real Estate solutions, E-Commerce, Classifieds, Corporate and online Magazines/Newspapers.

Feb 24 2020
Feb 24

Very often when developing or maintaining a site, clients ask me to create functionality in the footer that will scroll the page to the top.

I know this can be done with the helpful and wonderful Back To Top module, but I am the person who tries to have as few enabled contrib modules as possible on the site and save time on support in case a new version of the module appears.

Below I will show how to make similar functionality in 5 minutes.

Aug 23 2019
Aug 23

PHP/WEB Developer / Drupal Expert. More than 11 years of experience delivering Drupal based General Purpose solutions for different sectors such as Job Boards, Product Portfolios, Geo Coding, Real Estate solutions, E-Commerce, Classifieds, Corporate and online Magazines/Newspapers.

Aug 23 2019
Aug 23

PHP/WEB Developer / Drupal Expert. More than 11 years of experience delivering Drupal based General Purpose solutions for different sectors such as Job Boards, Product Portfolios, Geo Coding, Real Estate solutions, E-Commerce, Classifieds, Corporate and online Magazines/Newspapers.

Aug 23 2019
Aug 23

PHP/WEB Developer / Drupal Expert. More than 11 years of experience delivering Drupal based General Purpose solutions for different sectors such as Job Boards, Product Portfolios, Geo Coding, Real Estate solutions, E-Commerce, Classifieds, Corporate and online Magazines/Newspapers.

Dec 08 2018
Dec 08

Sometimes we need to build a rather complex search form with many options. We want to have total control under output, so we will override the default template by own because standard Drupal templates do not allow to the use the complex formatting. However, we can easily override the template with our custom theme or module.
All we need to know the ID of the form and the appropriate name of the template. For this, you can check using the following code: dump($form['#id']); and dump($form['#theme']); inside hook_form_alter() or hook_form_FORM_ID_alter().

In my example, we have: views-exposed-form-class-schedule-block-1 and views_exposed_form__class_schedule__block_1 , you should replace both with your values.

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web