I have problems configuring the search-result.tpl. Is it so, that the fields set in Search result view mode are always snippet'ized as plain text? I have for example a taxonomy term on each node, which I set to appear as link in the Search result view mode, yet it is always output as plain text.

I'm using Custom Search and Search API, if that matters.

2 Answers 2


Assuming Drupal 7 here, which thankfully has more options for you that Drupal 6.

I don't recall the last time I fully traced this out (and it's complicated), but search_excerpt does call strip_tags and check_plain.

You can take a look at search-result.tpl.php, template_preprocess_search_result(), hook_node_search_result() to see what your options are.

Personally, I would build up my own entries in $variables in the preprocess, and display them in the template. One option is to make a custom node view for the search results, uild it up with the UI, and then use this,something like:

function mytheme_preprocess_search_result (&$variables)
  $result = $variables['result'];
  $node = $result['node']; // not 100% positive that this is the right place in D7
  $variables['my_custom_search_result_view'] = node_view($node,

and then use $my_custom_search_result_view in search-result.tpl.php.

Not a full solution for you, but it should be a decent start.

  • Well, thanks MPD for your explanation, but this is actualy a piece that I understand :) What I don't get is - what is the use of Search Result view mode if the fields are not formatted as set in Manage Display. I disabled search-result(s).tpl files for a moment and cleared cache, thinking that they might override the view mode, but this is apparently not the case... Commented May 25, 2012 at 13:30
  • @Artur, I probably wasn't clear. I am suggesting not using $snippet at all in the template. Rather, make your own view mode, and use that in your search result template.
    – mpdonadio
    Commented May 25, 2012 at 13:41
  • Ah so! My brain stays behind sometimes. Yep, that worked perfectly! Thanks a bunch! Commented May 25, 2012 at 14:02

You can learn much more about this issue here https://www.drupal.org/node/1166114

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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