In my Omega 4.x subtheme I'd like to override theme_search_result().

When I implement mytheme_search_result() in the file mytheme/theme/search_result.theme.inc the override is not used. If I move the implementation to template.php, it overrides as expected.

Other theme overrides saved in mytheme/theme/*.theme.inc files are working correctly. One difference with theme_search_result() is that it uses a template by default, not a theme function (search-result.tpl.php).

Is this by design?

CommentFileSizeAuthor
#5 overrides.patch5.64 KBfubhy

Comments

fubhy’s picture

Status: Active » Closed (works as designed)

Yes, this is by design... Templates are overridden by templates, theme functions are overridden by templates... Do you have a good reason for why you need to be able to override the template with a theme function? If so, feel free to turn this into a feature request. Because this is absolutely possible with a few changes in the logic.

fubhy’s picture

Title: Theme include file for overriding theme_search_result() not loading correctly. » Allow template overrides in theme functions using separate files as supported by Omega
Category: bug » feature
Status: Closed (works as designed) » Active

Oh damnit, I missed a fundamental point there...

If I move the implementation to template.php, it overrides as expected.

So with native Drupal it's possible to override templates with theme functions. Right... So we have to support that too. I am sorry, I didn't even know that... I am such a dummy sometimes :)

milesw’s picture

Great, thanks for the clarification.

The reason I'm overriding with a theme function is to render search results with a view mode instead of a template.

fubhy’s picture

Status: Active » Fixed

I just committed the attached patch ... It fixes your problem and one other thing that I didn't consider when writing that lookup logic. It should now fully respect the theme trail and allow overrides of any sort (theme function overrides template file, template file overrides theme function) purely based on the weight of the theme in the theme trail of the current active theme (subtheme always overrides base theme / module... regardless of the type of the override [theme function vs. template file]).

This is the commit: http://drupalcode.org/project/omega.git/commit/2fd071a

fubhy’s picture

StatusFileSize
new5.64 KB

This is the patch.... Forgot to upload it :)

milesw’s picture

Wow, thank you. I can confirm this does indeed solve my issue. :)

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Updated issue summary.