You are here

function apachesolr_search_page_browse in Apache Solr Search 6.3

Same name and namespace in other branches
  1. 8 apachesolr_search.module \apachesolr_search_page_browse()
  2. 7 apachesolr_search.module \apachesolr_search_page_browse()

Handle browse results for empty searches.

1 call to apachesolr_search_page_browse()
apachesolr_search_search_page_custom in ./apachesolr_search.module
Mimics apachesolr_search_search_page() but is used for custom search pages We prefer to keep them seperate so we are not dependent from core search when someone tries to disable the core search

File

./apachesolr_search.module, line 1097
Provides a content search implementation for node content for use with the Apache Solr search application.

Code

function apachesolr_search_page_browse($empty_search_behavior, $env_id) {
  $blocks = array();

  // Switch in case we come up with new flags.
  switch ($empty_search_behavior) {
    case 'browse':
      if (module_exists('facetapi') && ($query = apachesolr_current_query($env_id))) {
        module_load_include('inc', 'facetapi', 'facetapi.block');

        // Get facet render elements.
        $searcher = $query
          ->getSearcher();
        $elements = facetapi_build_realm($searcher, 'block');
        foreach (element_children($elements) as $key) {
          $delta = "facetapi_{$key}";

          // @todo: order/filter these pseudo-blocks according to block.module weight, visibility (see 7.x-1beta4)
          $block = new stdClass();
          $block->visibility = TRUE;
          $block->enabled = TRUE;
          $block->module = 'facetapi';
          $block->subject = theme('facetapi_title', array(
            'title' => $elements[$key]['#title'],
          ));

          //$build[$delta] = $elements[$key];
          $block->region = NULL;
          $block->delta = 'apachesolr-' . $key;
          $block->content = $elements[$key][$key];
          if (!empty($block->content)) {
            $blocks[$delta] = $block;
          }
        }
      }
      break;
  }
  return theme('apachesolr_search_browse_blocks', $blocks);
}