I started to write all this, and by the time I finished writing, I had the issue solved and a patch ready to go... took me a while to get to this 3 line patch, but here's where it came from.

It appears that inheritance of layouts from a base theme to a sub theme was never intended to work, at least how I would expect it to.

From what I understand of context_layouts_get_layouts(), it is traversing up the theme inheritance tree and pulling in all context_layouts. However, when the layouts are merged down in to a single array, the layout's template location is not altered - meaning that a sub theme will inherit layouts from a base theme, but the sub theme is required to have those templates within its directory. This almost nullifies any inheritance altogether.

Head to context_layouts_theme() where context_layouts_get_layouts() is called. You'll notice that the output of context_layouts_get_layouts() is passed almost directly in to the theme template suggestions. If you recall, context_layouts_get_layouts() combines any templates found in the base theme and sub theme into a single array keyed by the sub theme name. This fails miserably once it gets to this step as all the context_layout template locations are set to the active theme, not the potentially base theme where they were generated. This makes drupal assume that the sub theme has the template files, which in most cases, it does not.

This patch simply moves the calculation of the template path from context_layouts_theme() in to context_layouts_get_layouts() where we have a little more details to determine if the base theme's template should be used. This is then passed back to hook_theme and all is good.

Note, this will break certain sites that didn't find this issue. With this patch, a sub theme's context layouts templates will only be found *if and only if* the layouts are defined in the sub theme's .info file. I actually really like this, but it very well could cause issues for some.

There definitely are other issues with base->sub theme context layouts inheritance. The main being that base themes that define context_layouts must be enabled, but I'll save that for another day and another issue.

Sorry for the long explanation, but it took me a while to figure out what was going on. The patch is actually really simple.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

core44’s picture

this failed on the latest dev for me. Heres an updated version that should patch latest dev. Any possibility of getting this committed?

ultimateboy’s picture

Assigned: ultimateboy » Unassigned
Status: Needs review » Reviewed & tested by the community

Thanks core44. Marking RTBC to maybe get some more attention to this issue.

antonranestam’s picture

Thanks core44! Worked like a charm.

colan’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Committed in a3d7fc8.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.