The template suggestions are being added in the wrong order so the more specific {$entity_type}__{$bundle}__{$view_mode} comes before {$entity_type}__{$bundle} when it should come after.

The mistake in the code is obvious in case my description is unclear.

CommentFileSizeAuthor
evm_theme_hook_suggestions-1.patch729 bytesAnonymous (not verified)

Comments

dave reid’s picture

Aren't suggestions supposed to be ordered specific to general? That way if you have a specific override it gets used in precedence over a more general one?

Anonymous’s picture

Maybe I phrased my issue poorly.

The patch fixes a problem where the array is being searched for a value, and if that value does not exist, it uses uses the index of the same value it just searched and did not find to splice a new value into the array. Since that value doesn't exist, the index is always 0, so it always adds it at the top.

It's clear that the code chunk is supposed to be just like the ones around it... it searches for the appropriate less specific thing to add something more specific after it. However, there's a typo in the code as it is. It searches for the thing it's trying to add.

dave reid’s picture

Status: Needs review » Reviewed & tested by the community

Makes sense. Will try to commit soon but I want to get a quick test written to confirm the suggestion behavior and ordering.

Anonymous’s picture

Dave:

I'd be happy to take on the task of writing a test to validate the suggestion order. Should this be part of this issue or should I open a new ticket?

dave reid’s picture

Status: Reviewed & tested by the community » Fixed

I'm working on some tests but I managed to reproduce the condition in which this happens by temporarily hacking some existing template suggestions in core to meet the conditions in the issue. Committed to 7.x-1.x. http://drupalcode.org/project/entity_view_mode.git/commit/56c2c13

Status: Fixed » Closed (fixed)

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