Skip to Content


Mediacurrent: One Word to Save your Project

Planet Drupal - 8 January 2016 - 6:57am

When faced with requirements that threaten to break the budget, blow the scope, derail the schedule and generally destroy a project, there is one magic word that can come to the rescue.


Asking “Why?” can help clarify, or neutralize, potentially destructive requirements and ultimately save the day.

Categories: Drupal

Deeson: The Curious Incident of the Wrong Theme being used after a Cache Clear in Drupal 7

Planet Drupal - 8 January 2016 - 4:30am

If you are using Drupal 7, have multiple themes enabled, are using hook_custom_theme() to choose the right one and find that after a cache clear the first page load chooses the wrong theme, then this blog post is for you.

On a couple of recent projects we have been using hook_custom_theme() to set one of several active themes for a given page request. This is a really useful hook allowing us to change the look and feel for different parts of the site. For example, we might use a different theme if a page is part of a Drupal Group which makes it look like a sub-site.

We were seeing an odd behaviour where the site default theme would load on the first page request after a cache clear, rather than the one we were returning from our hook_custom_theme implementation. Debugging showed that hook_custom_theme() was being fired and our implementation was returning the right option during the first page load.

Subsequent page requests following the first after a cache clear would result in the correct theme being used. The problem was that if that first page was opened by an anonymous user it would get varnish cached and all users would see the page in the wrong theme for a few hours.

The reason

The problem is the functions we were putting into hook_custom_theme().

hook_custom_theme() along with hoot_url_inbound_alter() and hook_boot() all get called very early in the drupal boot cycle and not everything has been properly initialised at this point, including the correct theme. If you call code that assumes this has happened then odd things can happen.

Following a cache clear the menu needs to be rebuilt - and this is a complex operation which calls a lot of code and prematurely sets the site to use the default theme.

If you access the menu, for example by using ​menu_get_item, ​menu_get_object or even node_load​ in these functions you will trigger a menu build too early and initialise the default theme. 


The solutions are to keep the code in the hooks which run before the theme is initialised as simple as possible.

For example, do you need to load the menu to decide the theme or can it be infered from the current path? Rather than load the whole node, can you do a simple db_select on the node table to get the information you need?

Categories: Drupal

Bringing Finding Monsters Adventure to VR Part II - Level Design - by Thiago Beto Alves Blogs - 7 January 2016 - 11:21pm
This is a series of articles to present the essentials for building up FMA VR version from Game Design standpoint. Part II explains level design changes that allowed creation of unique levels best fit for VR environment.
Categories: Game Theory & Design

Cyber Security for Online Gaming - by AJ Mil Blogs - 7 January 2016 - 11:21pm
I was just transferred into Cyber Security and wanted to find out in the gaming/gambling community what is important to you? Thanks for your input.
Categories: Game Theory & Design

Let the Inner Novelist in You Market your Game - by Jonathan Epstein Blogs - 7 January 2016 - 11:21pm
This post is about content creation. Specifically, writing short stories about the game to keep fans interested, updated, and to help show your world to them.
Categories: Game Theory & Design

I get removing Ads with a micro-transaction but... - by Jeff LaFlam Blogs - 7 January 2016 - 11:19pm
We understand why there is a micro-transaction for removing ads when you get a game for free but you should follow a simple rule when you do it.
Categories: Game Theory & Design

Why are connected features so important in F2P games? - by Mike Herron Blogs - 7 January 2016 - 11:19pm
The key social and connected features you need to implement in your game to successfully utilise the F2P model.
Categories: Game Theory & Design
Syndicate content

about seo