0

I have created a custom search module that integrates with Drupal 7 Search Interface. My module is called history_search and in the module I have two files: history_search.module and history_search.info.

These are the contents of my history_search.module:

<?php

function history_search_search_info()
{
    return array(
        'title' => 'History',
        'path' => 'history',
        'conditions_callback' => 'history_search_search_conditions_callback',
    );
}

When I try to use it, it works correctly: Drupal creates a search tab for me and uses the results data I provide. However, I can't figure out how to get it to use my template suggestion for a single search result. I created a file in my module's folder called search-result--history_search.tpl.php, however it doesn't seem to be used when I perform searches in my module. However, if I place this file in my theme, then it suddenly works fine with no problems.

So my question is, how do I get Drupal to use search-result--history_search.tpl.php when I place it in my module's folder?

  • Your after YOURMODULE_registry_alter(&$theme_registry) function. – Alex Gill May 2 '13 at 8:50
  • 2
    @AlexGill did you mean hook_theme_registry_alter ? – Beebee May 2 '13 at 8:58
  • Ahhh bugger, yes indeed, good spot Beebee! – Alex Gill May 2 '13 at 9:02
  • 1
    Great suggestions guys, I solved it! – rkrv. May 2 '13 at 9:29
0

Thanks to the comments from @AlexGill and @Beebee I was able to figure out what's the actual suggestion name for my template file. Here's how I solved it:

<?php

function history_search_theme()
{
    return array(
        'search_result__history_search' => array(
            'template' => 'search-result--history_search',
            'path' => drupal_get_path('module', 'history_search'),
            'base hook' => 'search_result',
        ),
    );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.