Viewport module ready for Drupal 8

A tiny yet useful tool for administrators to define the viewport of pages on their site

Photo of Salvador Molina Moreno
Wed, 2016-07-13 16:45By salva

Last week I had the chance to finish off the port of the Viewport module to Drupal 8. At its core, it's a very basic utility that allows site administrators to use configure the viewport values that they want to use on the site (or just on certain pages). Originally, we had to develop this module for a client that wanted to embed certain games for tablets, which required very specific viewport values in order to work. 

Even though there was already a D8 version of the module, it dated from 2013, when Drupal 8 was way different to what it is nowadays, which means that version was not even working anymore. As I've been spending some time to catch up with Drupal 8 recently, I decided to start with this one, as it's the simplest project in the list of modules that I've created or maintain, yet it had enough components to get familiar with plenty of elements of the new Drupal codebase.

Interested about using it on your site? Then head over to the project page and download the Drupal 8 version. After installing it, this is the settings page that should welcome you in the Appearance section of the site.

viewport settings ui

Pretty simple, indeed, as there is nothing else you can add to a viewport tag. Right now the stable release will stay as a dev release, since I want to do a bit of refactoring to get rid of the last bits of procedural code and move them into a simple service that I can put in a class, and add unit tests for them. At that point, the 8.x-1.0 tag for the stable release will be added.

Next one?

While working on the port, I kept a diary with plenty of notes about the new things that I came across, and several links to the related documentation on I found it a really good way to absorb all the information, instead of simply fixing and forgetting.

The sad thing is that after finishing this, I wasn't entirely satisfied. There are still tons of things to catch up with, and only so much time in the day. The good news is that my list of contrib projects still has some good candidates for a port, that would allow me to explore other parts of the framework. The User Homepage module is one of them, and it may be the next one. Watch this space!