Latest posts

Browse topics

Drupal 8 Custom Taxonomy Term Pages with Views

By default, out of the box, Drupal taxonomy term pages are styled kind of ugly, but with the help of just a few simple tweaks, we could style them as we wish, just by using CSS. In today's Drupal tutorial series, I will provide a simple how-to on how to create custom Drupal 8 taxonomy term pages using views.

Luckily, you won't need to install any additional modules, as in Drupal 8, views are already built in the core, and if you are already familiar with how to style taxonomy term pages in Drupal 7, it will be an easy task in Drupal 8, as most of the steps involved are the same.

Although this aticle was writtne for Drupal 8, most of it still applies in Drupal 9 and Drupal 10 versions. If you need any help with configuring Drupal taxonomy pages I might be just the person you're looking for. As the founder of Terramatris.eu, a Drupal development agency, I have years of experience working with this platform and helping clients achieve their goals through custom Drupal installations. Learn more at Terramatris.eu

Default taxonomy term page view in Drupal 8

Default taxonomy term page view in Drupal 8

In the above example, you can see the default taxonomy term page view (taxonomy/term/%) in Drupal 8. For this tutorial, I'm using Tourgeorgia.eu website, listing tours in Georgia where each tour is tagged with predefined taxonomy, for example, cultural tour, spiritual tour, and so on.

Though technically speaking, taxonomy term pages are not the ones generating the most page views and in fact, are rarely visited, that doesn't mean we should leave a bad user experience. On the other hand, taxonomy term pages might be used in your Drupal's SEO strategy, and in case of that - even more, it's time to make them rock.

Drupal views for Taxonomy term pages

  • Go to the views page (admin/structure/views), edit the Taxonomy term page
  • Under Format, change display from Content to Fields
  • Add fields, like title, body, image, and custom block
  • Exclude all, but custom block fields from the display
  • Construct your display in a custom block using replacement variables, you should add here CSS classes as well
  • Apply CSS to your themes style sheet

Here is the final result

Custom Drupal 8 taxonomy term page

Custom Drupal 8 taxonomy term page

Now, looks much better. As you can see I have displayed additional custom fields on taxonomy pages as well, like price,  and even a direct link to the booking form. The sky is the limit when working with taxonomy term pages in Drupal.

Tip: If you are figuring out how to remove subscribe to RSS link from taxonomy term pages, go back to the taxonomy term page view, select feeds to display, and under the Feed setting remove Attach to Page

Now you have some basic knowledge of how to create custom Drupal 8 taxonomy term pages using views.

In case you are using more than just one vocabulary for taxonomy terms, you could create some additional rewrites per vocabulary. Personally, I prefer using just one taxonomy term page display, with most rewrites done already in views.

Like in the case of tourgeorgia.eu - we have two vocabularies, one for tour type and other tags in free format, using rewrites in Drupal view construct page it's not a problem to display on one page two different displays (see example)

Taxonomy terms from different vocabularies on same taxonomy term page in Drupal

Taxonomy terms from different vocabularies on the same taxonomy term page in Drupal

Here we can see two nodes, both tagged with Tbilisi, the first one is an article, and as you can see from the display it shows an image, title, description, and read more button, while the second is a tour, displaying additional info on the same taxonomy term page, tour type, duration, price, and booking.

When constructing a custom taxonomy view page, make sure to list all possible fields and then use the hide if empty option to rewrite the final result.

Another great feature of Drupal 8, is displaying taxonomy term descriptions on the taxonomy term page, out of the box. It was kind of complicated to get this done in Drupal 7, see: How to List Drupal Child Terms on Taxonomy Pages with Views

Taxonomy description in Drupal 8

Taxonomy description in Drupal 8

There is nothing much you should do to print taxonomy term descriptions on the Drupal 8 taxonomy term page, just edit the taxonomy term and add a brief term description, the rest is handled by the taxonomy/term/% views page.

As you can see - the sky is the limit when dealing with taxonomy term pages in Drupal. If implemented with SEO strategy, well optimized taxonomy pages can help to improve overall site rankings in Google search. 

If you're in need of someone with expertise in Drupal development and module configuration, I might be just the person you're looking for. As the founder of Terramatris.eu, a Drupal development agency, I have years of experience working with this platform and helping clients achieve their goals through custom Drupal installations. Learn more at Terramatris.eu

EU Cookie Compliance For Drupal 8 Website

I'm not an expert in EU laws, but as far as I remember since 2012 there have been passed a law, so called EU Cookie Compliance law, asking website located in the territory of European Union to provide cookie disclaimer to website visitors if any cookie installed on website. 

To play safe, I have enabled cookie information bar on my blog (you can see it in the bottom of each page)

As, recently I started Drupal 8 development on .eu domain website, which actually is hosted from EU territory I decided to wrap up a simple tutorial on best practice how to enable EU cookie compliance notification bar for Drupal 8 websites.

The good news, there is a special module to handle EU cookie directive: EU Cookie Compliance

This module intends to deal with the EU Directive on Privacy and Electronic Communications that comes into effect in the UK on 26th May 2012. From this date on, you run the risk of enforcement action if you are not compliant or visibly working towards compliance. More information can be found here: Privacy and Electronic Communications Directive 2002

The above information applies to the UK however the EU law will be enforced in all EU countries and hence the module can be used everywhere in the EU.

By enabling and configuring the module you will demonstrate to the regulator that you, as the owner of the website:

  • are doing as much as possible to reduce the amount of time before your visitors receive information about cookies (information appears as soon as a visitor enters the site).
  • are providing your visitors with options. (find out more about cookies, do not browse if you disagree).
  • ensure that the information on cookies is readily available to your visitor(visible pop-up at the bottom of the screen).
  • are visibly working towards compliance (even if you do not perform a full cookie audit, it's clear that some effort has been made).

Right, now when you are familiar how this module can help you:

Hope, it helps!

How to create related content block using taxonomy term in Drupal 8

There is no secret that related content can help to improve over all page views for website. More page views means more engaged website visitors, resulting in more sales and higher profit.

In today's Drupal tutorial I will write how to make related content block using taxonomy term field in Drupal 8. For Drupal 7 tutorial see: Related nodes based on taxonomy terms

In short, if you are already familiar how to create related content block in Drupal 7, there is no huge difference in Drupal 8. If you are new to Drupal, keep reading.

Requirements:

  • Content type with taxonomy term enabled. 

For this tutorial I will use live example from tourgeorgia.eu here we have content type Tour and attached taxonomy term field: Tour type. What we want to build is a related view listing related tours from the same category as given article, for example cultural tour.

Related taxonomy block in Drupal 8

Related taxonomy block in Drupal 8

You can see a live preview here

Drupal 8 views for related taxonomy term

Create a new content based block view - give it a nice name, Related Items (or something) add title, image and body fields to it. We will need to use 2 contextual filters. Id and Has taxonomy term id.

Configure Id filter as following:

  • Provide default value: Content ID from URL
  • Under More tab - Check next to Exclude

Configure Has taxonomy term id as following:

  • Provide default value: Taxonomy term ID from URL
  • Uncheck: Load default filter from term page
  • Check next to: Load default filter from node page, that's good for related taxonomy block
  • Multiple value handling: Filter to items that share any value
  • Check next to Reduce Duplicates
  • Under more tab check: Allow multiple values and Allow multiple values to work together.

That's it. Save your view (be sure you have created a block not page view). Now you just need to add block you just created to your sites theme region.

It is up to you have you will decide to theme your related items block. Sky is the limit for you creative work. You can add author field, date field, rating field.. so do you can add some filters to show most viewed related nodes content. In this example I gave to you, is just a basic to help you to get started for showing related item list on your Drupal powered site.

N.B. On my example Live preview from views page is not working, but it actually works when added to region in your theme.

Rainy day in Tbilisi - Time Lapse Video

That time of the year has come and as usual, in April I return to photograph that lovely brick wall opposite to our apartment, turning green. This year I decided to excel in time-lapse photography and video.

A few months ago I bought an intervalometer (around Christmas time) and today was actually the first time I put it on real action. 

I did a few tests to see how intervalometer actually works, and once get the basic understanding put it to capture 120 shots with 30-second interval (making 30 minutes in total). On-Camera settings, its manual mode, f 11, and ISO 400 (as it was a rainy day, I wanted to make it bright enough). Shot in RAW mode.

Making time-lapse videos are fun, during this 30-minute session I was able to make a coffee, upkeep some things on the blog, and do other stuff. Making this time-lapse involved using Adobe Lightroom for post-processing images, and Adobe Premiere making a video.

Adobe Lightroom

Import images to Lightroom, adjust some settings if needed, auto-sync all images, export as jpg 1920 pixels, make sure to remove the watermark

Adobe Premiere

The final comp was made in Adobe Premiere adding a sound effect (from free libraries)

I hope to apply my newly developed skills to make some nice star trails photography in the short future. My First Star Trail Photography

A tutorial for creating HDR images in Photoshop

HDR stands for High Dynamic Range, and it is a technique in which many images – usually around 3 or 5 – are merged together, so that details from all the different images show up in the final HDR image. It is simply using the dynamic range over many exposures in one single image.

[block:block=34]

Photoshop is a great and very effective tool for merging the series of photos of the same scene you have taken, to give an HDR image with lots of details and tones. In this article, I will tell you how to take photos for merging them into an HDR image, and then how to use the photos for the actual process of making an HDR image in Photoshop.

How to take source images for a final HDR image

The logic behind an HDR image is this – one single photo cannot show all the details from the highlights and the shadows. But, if we over-expose an image (make it brighter), we start getting details from the shadow region. Also, if we under-expose an image (make it darker), we get details from the highlights. What if we could do both the things together ?

HDR, in simple words, is combining an over-exposed image with an under-exposed image and a few other photos of the same scene (just for having even more detail), so that we get one single photo with multiple light levels.

So, to take the source images – the ones you'll be combining – all you have to do is take the same photo with different exposure levels.

The best way to do this is to first fix your camera on a tripod and setup your composition. You don't want your camera moving, because then there will be no similar images to merge. Also, shoot in RAW for more latitude while processing the images in Photoshop, although the method works even for JPEGs.

Once your camera is ready, take a photo that is metered by the camera itself. Not under-exposed, not over-exposed. This image is your base image, and it is basically a photo that the camera will take if it was in Auto Mode.

Now, you need at least 2 more photos to merge them all into an HDR image. Change your shutter speed to change the exposure. If you change aperture, the depth of field will change, which will make some areas of your photo unwantedly blurry. Changing ISO is also possible, but try to avoid it so that you get a clean image with no noise.

Make sure you have an under-exposed image by 1 stop at least. You can also go further and take an image under-exposed by 2 stops. Do the same the other side. Over-expose the scene by a stop, and then by one more stop.

Now, you have 2 under-exposed, 2 over-exposed, and 1 base image. You could also have done this using an 'Auto Bracketing' feature if your camera has one. More the number of images, more the information available for the final merged HDR photo.

HDR image

So, you have 5 images – or more – with different exposures, all with the same composition and still subjects. Keeping your camera stable is very important, otherwise the camera shake and movement of the subject will cause ghosting and will also make merging all images into one very tricky.

How to merge all images in Photoshop

Once you have the source images ready on your computer, you can open Photoshop and begin working on merging your images for HDR.

Merging HDR in Photoshop

Merging HDR in Photoshop

1. Open Photoshop and choose File > Automate > Merge to HDR. Here, you will get the option of choosing all your source images.

2. If in case you are unsure about camera shake and think that there is some change in the composition in the source images, select the option “Automatically Align Source Images”.

3. When you click OK, the computer will process the files and you will have to wait for a few seconds. Now, choose the 32-bit depth for the highest amount of tonal range. 8-bit and 16-bit files cannot store the entire range of light.

4. Now, the image you will see is a 32-bit preview of the final image with the source images on the side. Check for some ghosting or weird movement in the shot and if there is any, remove the source image which has the movement in it.

5. The 32-bit preview has a lot of information, most of which your computer screen cannot show. So, make sure that you save this file for later use as a 32-bit (tiff, .pbm etc) HDR full of details.

6. The merged result is a floating-point 32-bit image. You can view the available tones by sliding the White Point slider. This slider won’t change the image, it is there for you to examine the range of tones, because a monitor is incapable of displaying the whole tonal range.

7. The 32-bit image will still seem darker than you may want, but once you convert it into a 16-bit or 8-bit image, it will start to look better. You'll need to use the 8-bit image for sharing and emailing and uploading it to social media.

8. Choose Image > Mode > 8-bit. Here, you'll get options to actually bring out the exact exposure you want. You’ll see an HDR Toning Dialog box, with 2 options – Exposure and Gamma.

4. Now, the image you will see is a 32-bit preview of the final image with the source images on the side. Check for some ghosting or weird movement in the shot and if there is any, remove the source image which has the movement in it.  5. The 32-bit preview has a lot of information, most of which your computer screen cannot show. So, make sure that you save this file for later use as a 32-bit (tiff, .pbm etc) HDR full of details.  6. The merged result is a floating-point 32-bit image. You can view the available tones by sliding the White Point slider. This slider won’t change the image, it is there for you to examine the range of tones, because a monitor is incapable of displaying the whole tonal range.  7. The 32-bit image will still seem darker than you may want, but once you convert it into a 16-bit or 8-bit image, it will start to look better. You'll need to use the 8-bit image for sharing and emailing and uploading it to social media.  8. Choose Image > Mode > 8-bit. Here, you'll get options to actually bring out the exact exposure you want. You’ll see an HDR Toning Dialog box, with 2 options – Exposure and Gamma.

9. If you want an image with lots of contrast, lower the gamma. For less contrast, raise the gamma. Finally, adjust the exposure to get the desired image. There will be other options like Local Adaptation, but these are advanced tools and need another article itself.

10. If you are happy with the image, just click OK and you are done. You can also make further edits like shadows, highlights and saturation. Experiment and try to see how these settings change your image.

This is all!