I have a bootstrap 3 subtheme in my site and everything is fine. When I use custom search module (https://www.drupal.org/project/custom_search) The search results displays only numbers, but not the result.

I copied the file search-result.html.twig into the templates folder of the subtheme and still not getting the results.

I tested with bartik and a testing omega subtheme and works fine.

Comments

FSar created an issue. See original summary.

chris_n’s picture

Im experiencing the same issue: Drupal 8.4, Bootstrap-Module 8.x-3.6 and Custom Search 8.x-1 beta6
When i switch to Bootstap as default main-theme, i can see the sam issue.

When i switch to bartik it works fine.

Stockticker’s picture

+1

web247’s picture

I gave it a few tries and, so far, I could not find any issues with bootstrap, but with the way custom_search module handles templating for the result set and result item. Also, on a cache clear, I see this: Notice: Undefined index: plugin_id in custom_search_theme_suggestions_item_list__search_results() (line 108 of modules/contrib/custom_search/custom_search.pages.inc).

Although, it seems to be working in other themes.

Maybe someone else can run a few tests ?

vinyl_roads’s picture

I have the same issue when i use my Bootstrap sub theme. It works with Bartik.
. Did you find a solution ?

If I try to override twig template in /modules/contrib/custom_search/templates/ with item-list--custom-search-results--.html.twig, it works (I can see results) but randomly as the module sometimes try to load the file in /modules/contrib/custom_search/templates/

vinyl_roads’s picture

Issue tags: +custom search module

I have the issue with custom_search 8.x-1.0-beta6. I have no issue if i revert back to custom_search 8.x-1.0-beta5. I still don’t know if the issue comes from Custom Search module or Bootstrap Theme. Need to investigate.

markcarver’s picture

Project: Bootstrap » Custom Search
Version: 8.x-3.1 » 8.x-1.x-dev
Component: Theme Settings » Code
Issue tags: -bootsrap 3, -Drupal 8.x, -custom search module

This is likely due to bad theming/render array construction of some kind in the module. The only code that the Bootstrap base theme touches (in regards to "search") is very minor cosmetic changes, nothing structural:

https://drupal-bootstrap.org/api/bootstrap/templates%21block%21block--se...
https://drupal-bootstrap.org/api/bootstrap/src%21Plugin%21Form%21SearchB...
https://drupal-bootstrap.org/api/bootstrap/src%21Plugin%21Form%21SearchF...

leopinzon’s picture

Same problem around here, help guys!

Have the same exact error as web247 in the report log.

leopinzon’s picture

The problem is caused by the custom_search.module in the hook custom_search_theme_registry_alter, because it is hardcoding the template'sPATH used to render the search results:

/**
 * Implements hook_theme_registry_alter().
 * @see https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/function/hook_theme_registry_alter
 */
function custom_search_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['item_list__search_results'])) {
    $theme_registry['item_list__search_results']['template'] = 'custom-search-results';
    $theme_registry['item_list__search_results']['path'] = drupal_get_path('module', 'custom_search') . '/templates';
    $theme_registry['item_list__search_results']['variables']['filter_position'] = FALSE;
    $theme_registry['item_list__search_results']['variables']['filter'] = '';
  }
  if (isset($theme_registry['search_result'])) {
    $theme_registry['search_result']['template'] = 'custom-search-result';
    $theme_registry['search_result']['path'] = drupal_get_path('module', 'custom_search') . '/templates';
  }
}

Anyway as far as I saw, it is not an easy one to correct, let me explain:

* The module uses its own template names for the search result and the result items instead of the default ones used by Drupal.
* The module prepares and use its own variables that are passed to the templates in order to show the results.

So the workaround if we would want to override the module's templates, the magic would have to be done in the above's hook, leaving it to Drupal to decide which is the best location to get the template from.

markcarver’s picture

Yeah... no... that is a horrible implementation, especially in 8.x.

There is absolutely no need to alter the theme registry like this.

The theme system/hooks/templates in 8.x has matured "enough" so that if custom markup is truly needed, it should be built up using render arrays with appropriate and existing theme hooks.

Core already provides the item_list__search_results theme hook suggestion, so you can simply implement your own preprocess custom_search_preprocess_item_list__search_results(&$variables) function.

You can preprocess the items however you want, recreating each item as you see fit since item_list items can take render arrays in 8.x now.

Stephen Ollman’s picture

@markcarver...how does a non programmer implement your preprocess function?

Shouldn't this work out of the box, it is after all a pretty fundamental function of the module?

I look forward to seeing this one resolved.

Thanks for everyone's help.