DrupalCon Dublin 2016

4th October 2016

The European DrupalCon was held in Dublin from 26th - 30th September and I went along with a couple of colleagues to learn a few things about Drupal. I have been back from the conference for a few days now, and I wanted to write down some of the highlights of the conference in a blog post. There is a lot going on at DrupalCon and with 2000+ people, 3 full days of sessions, 2 tutorial days, multiple parties and over 10,000 cups of coffee consumed there is too much to write about here.

Drupal 7: Redirect Users From Unpublished Content

9th August 2016

I was recently asked to implement a feature on a Drupal site where all nodes of a certain type would redirect to a main listing page if that node had been unpublished. The problem in doing this is that if a post is unpublished then Drupal will issue an access denied response quite early on in the boot process. When the menu item is loaded it goes through an access callback which sees that the post is unpublished and issues an access denied before anything else can happen. So in this situation you can't use things like Rules to redirect users as the rule is never triggered.

Drupal 8: Detecting An Anonymous User

28th June 2016

To find out if the current user is anonymous use the following.


This can be used as part of an if statement like this:

Drupal 8: Get The Current Language

26th April 2016

To get the currently selected language on a Drupal 8 site you need to run the following.

$language = \Drupal::languageManager()->getCurrentLanguage()->getId();

This will return the 2 character ISO language code for the language. So for English this would be "en".

To get the language name instead of the language code use this.

$language =  \Drupal::languageManager()->getCurrentLanguage()->getName();

Drupal 8: Include A Twig Template

1st April 2016

When creating re-usable theme templates in Drupal 8 it's quite easy to include that template by using the following snippet.

{% include directory ~ '/templates/parts/footer.html.twig' %}

This assumes that your footer.html.twig template file is kept in the same theme as the template you are working on. It's also good practice to add the template part to a directory called 'parts' or 'components' to separate them from the normal Drupal templates.

DrupalCamp London 2016: A Review

1st April 2016

DrupalCamp London, now in it's 4th year, was held of the weekend of the 4th, 5th and 6th of March at The University of London campus in London. Myself and a few other developers from Manchester headed down for the weekend to attend. I wasn't able to attend the CXO day on the 4th, but we were all in attendance for the camp event.

Overriding Drupal 7 Theme Functions In Module Files

16th December 2015

When overriding theme functions in Drupal 7 you would normally copy the theme function into the template.php and alter it to suit your needs. This isn't always convenient though, especially if you are trying to abstract functionality into modules and not have code in your theme layer that is reliant on module code. If you add theme override functions to your module files then they won't do anything as Drupal isn't looking for them there and won't pick them up.

Interrogating DNS Records

30th November 2015

DNS records, as many of you will already know, are commonly used to translate a human readable address into an IP address. This means that instead of visiting a website by typing in it's IP address you can just type in the easy to remember DNS address. I won't talk too much about how DNS records work here, but if you want to know more then you can read the awesome and easy to understand how DNS works commic.

DrupalCamp Scotland 2015: A Review

9th November 2015

DrupalCamp Scotland 2015 consisted of a Friday training day, followed by a day of talks and sessions on the 6th and 7th November.

The training day was based around Drupal 8 and had us looking at installation, configuration, and development. In the morning we set up a couple of Docker containers (on a Digital Ocean box) to run Drupal 8 from and then looked at the Drupal command line tool when setting up the system. Once installed we looked at the system structure and how the configuration management system worked. In the afternoon we created modules and themes, also using the Drupal console to generate some of the code fragments. I think the use of Docker on a remote server was a good idea in getting everyone up and running on the system without having to rely on local LAMP stacks or whatever. The training day was really good and I was able to swap lots of ideas and techniques with the trainers and other attendees.

PHPNW15: A Review

PHPNW is the 8th annual PHPNW Conference, and I think I'm lucky to be one of the few who have attended every year. This was something that Jeremy Coates mentioned out as we sat down the introductory session, but it was also good to see lots of new people attending the conference as well. It was a great conference with a great community feeling.

The keynote this year was by Meri Williams, who talked about Stealing People Lessons from Artificial Intelligence. Meri's career has been in both development and project management and she was able to use lessons learnt during her PhD thesis on artificial intelligence in order to think about how people respond to work. The concept sounds a little un-emotional at face value, but part of the principles of AI is making sure that all agents have their own goals. Meri was a funny and engaging speaker who talked about all kinds of interesting aspects of how people learn and grow.

philipnorton42 Sat, 10/17/2015 - 21:41