Hi,

I have done everything the way I think it should be right:

on the "Manage Display" tab under "Custom display settings" I have checked the option "Search result" and then used panelizer to tweak this view mode.

But on the search results page the displayed nodes are still shown according to the original search-result.tpl.php template and not my panelized settings.

Please provide some help on this. Thanks a lot!

Comments

leonardo.drupal’s picture

Hi,
I was having the same problem. I almost gave up on panelizer and planned on using the Display Suite Search Module. But as soon as I turned on the Display Suite Search Module, the panelized search results started showing up in the search.
I have not configured or even enabled the Display Suite Search in the Search configuration. I merely enabled the module.

I do not know what the connection is between the two modules but it worked for me. Maybe you can try.

Leo

joelstein’s picture

Title: Cannot get search result view mode to be panelized » Panelizing 'search index' and 'search result highlighting input' view modes
Status: Active » Needs review
Related issues: +#2472519: Can't substitute failover default view mode
StatusFileSize
new2.29 KB

First, try applying the patch at #2472519-4: Can't substitute failover default view mode, which resolves some issues substituting view modes.

Then, try adding something like to a custom module, which will populate the search index for nodes managed by Panelizer, and also populate the search result highlighting input from the rendered 'search_result' view mode, according to however you've got Panelizer configured.

You can enable the 'Search index' and 'Search result highlighting input' view modes on your content type display settings, and then configure these with custom panelized layouts. Or you can substitute them with the 'Default' or 'Page manager override' view modes. Or, you can leave them all disabled, and simply enable the 'Default' panelizer with a fallback to 'Page manager override'.

For me, this solution works like a charm, fully indexing my node content, and populating the eligible search result highlighting terms with words from the rendered node content.

/**
 * Implements hook_node_update_index().
 */
function MY_MODULE_node_update_index($node) {
  // Populate search index for nodes managed via Panelizer if 'search_index'
  // view mode is configured to do so.
  if (
    ($handler = panelizer_entity_plugin_get_handler('node'))
    && ($view_mode = $handler->get_view_mode('search_index', $node->type))
    && $handler->is_panelized($node->type . '.' . $view_mode)
    && !empty($node->panelizer[$view_mode])
    && ($info = $handler->render_entity($node, $view_mode))
  ) {
    $build['#view_mode'] = $view_mode;
    $build['#theme'] = 'panelizer_view_mode';
    $build['#panelizer'] = $node->panelizer[$view_mode];
    $build['#panelizer_content'] = $info;
    $build['#panelizer_handler'] = $handler;
    $build['#panelizer_entity'] = $node;
    $build['#panelizer_bundle'] = $node->type;
    $build['#panelizer_entity_id'] = $node->nid;
    return drupal_render($build);
  }
}

/**
 * Implements hook_node_search_result().
 */
function MY_MODULE_node_search_result($node) {
  // Populate search result highlighting input for nodes managed via Panelizer
  // if 'search_result' view mode is configured to do so.
  if (
    ($handler = panelizer_entity_plugin_get_handler('node'))
    && ($view_mode = $handler->get_view_mode('search_result', $node->type))
    && $handler->is_panelized($node->type . '.' . $view_mode)
    && !empty($node->panelizer[$view_mode])
    && ($info = $handler->render_entity($node, $view_mode))
  ) {
    $build['#view_mode'] = $view_mode;
    $build['#theme'] = 'panelizer_view_mode';
    $build['#panelizer'] = $node->panelizer[$view_mode];
    $build['#panelizer_content'] = $info;
    $build['#panelizer_handler'] = $handler;
    $build['#panelizer_entity'] = $node;
    $build['#panelizer_bundle'] = $node->type;
    $build['#panelizer_entity_id'] = $node->nid;
    $node->rendered .= drupal_render($build);
  }
}

Attached is a patch which adds these two hooks to Panelizer, which greatly improves the out-of-the-box experience using Panelizer and core Search.

damienmckenna’s picture

Category: Support request » Feature request
Parent issue: » #2155813: Plan for Panelizer 7.x-3.2 release

I was honestly surprised it didn't work out of the box :-\

damienmckenna’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Will work on tests for this tomorrow.

damienmckenna’s picture

Status: Needs work » Fixed

Committed.

damienmckenna’s picture

The code looks ok, so I've punted the tests to #2757415: Add tests for core search index handling.

joelstein’s picture

Status: Fixed » Closed (fixed)

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