Apache Solr Search Integration has a great feature of being able to create additional search pages through the GUI. It would be useful for themers to be able to modify the display of the search pages on a per-page basis. The request is to add a template hint to the search-results.tpl.php template that follows the search_results__MODULE__PAGE-ID nomenclature.

Comments

cpliakas’s picture

Status: Active » Needs review
StatusFileSize
new631 bytes

The attached patch makes the suggested change.

nick_vh’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)

committed to D7. Thanks!

killua99’s picture

Status: Patch (to be ported) » Needs work
+++ b/apachesolr_search.module
@@ -1410,6 +1410,10 @@ function apachesolr_search_preprocess_search_results(&$variables) {
+
+    // Add template hints for search pages.
+    $page_id = $variables['search_page']->page_id;
+    $variables['theme_hook_suggestions'][] = 'search_results__' . $variables['module'] . '__' . $page_id;

This part exist:

<?php
/**
 * Template preprocess for apachesolr search results.
 *
 * We need to add additional entity/bundle-based templates
 */
function apachesolr_search_preprocess_search_result(&$variables) {
  // If this search result is coming from our module, we want to improve the
  // template potential to make life easier for themers.
  if ($variables['type'] == 'apachesolr_search') {
    $result = $variables['result'];
    $variables['theme_hook_suggestions'][] = 'search_result__' . $variables['type'] . '__' . $result['entity_type'] . '__' . $result['bundle'];
  }
}
?>

Need anything else?

drupalninja99’s picture

This is a great idea!

pwolanin’s picture

Version: 6.x-3.x-dev » 7.x-1.x-dev
Status: Needs work » Active

related bug fix: #1717490: Search result template suggestions relies on non-required fields

Let's also work some more on D7 - feels like this tpl suggestion should also (or insteaD) be based on environment ID?

Same with the search result one.

cpliakas’s picture

-1 to templates only based on environment. You loose a ton of flexibility if you have to clone the environment for every search page you want to override. I have seen too many use cases where this would be problematic. +1 for also adding hints based on environment in case you want to bulk modify the the display of a group of pages.

pwolanin’s picture

I was thinking rather that that would be an alternative suggestion, not replacing what's already there for pages.

cpliakas’s picture

Perfect. I misunderstood. Sorry about that. In that case, definitely inline with what you are proposing.

nick_vh’s picture

StatusFileSize
new1.73 KB

So, let's see if this makes people happy?

nick_vh’s picture

Status: Active » Needs review
nick_vh’s picture

StatusFileSize
new1.19 KB

fewer checks

nick_vh’s picture

StatusFileSize
new1.7 KB

Whoeps, we forgot to convert it to arrays!

pwolanin’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)

committed, needs to be ported?

nick_vh’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.52 KB

ported, tested it by checking the $variables array. Looking good

nick_vh’s picture

Status: Needs review » Fixed

committed

Status: Fixed » Closed (fixed)

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