Search Results Listing Empty

Created on 22 December 2023, about 1 year ago
Updated 31 July 2024, 5 months ago

Problem/Motivation

The Search Results shown is empty listing.

Steps to reproduce

  • Install Module
  • Add Custom Search Block
  • Search for the text
  • You will see the search results listing, having ample of items in it however, empty rows displayed on page.

Proposed resolution

In function function custom_search_preprocess_item_list__search_results(&$variables) , there is a line viz., $variables['items'][$key]['value'] = \Drupal::service('renderer')->render($item['value']);. There is no "value" key in results array, so it needs to be removed and replaced by "#result".

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Downport

Version

1.0

Component

Code

Created by

🇮🇳India sandip27

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sandip27
  • 🇮🇳India sandip27

    Here is the patch for the fix.

    Patch # 1

  • Status changed to RTBC 12 months ago
  • Status changed to Downport 12 months ago
  • 🇵🇪Peru jcarhuazv

    Thanks @sandip27 for that patch. I'm new to this forum so I hope to contribute correctly.
    For the results list to look correctly it is also necessary to change 'item.value' to 'item' in the results template custom-search-results.html.twig.

    index a2335c8e..81df7bf0 100644
    --- a/modules/contrib/custom_search/templates/custom-search-results.html.twig
    +++ b/modules/contrib/custom_search/templates/custom-search-results.html.twig
    @@ -31,7 +31,7 @@
           {%- endif -%}
           <{{ list_type }}{{ attributes }}>
             {%- for item in items -%}
    -          <li{{ item.attributes }}>{{ item.value }}</li>
    +          <li{{ item.attributes }}>{{ item }}</li>
             {%- endfor -%}
           </{{ list_type }}>
           {%- if filter_position=='below' -%}

    Regards.

  • 🇮🇳India amittgaur Chandigarh

    Hi,

    Here is the another way to fix this if you are getting the same error in your search result.

    in custom_search/templates/custom-search-results.html.twig.
    Replace
    <li{{ item.attributes }}>{{ item.value }}</li>
    with
    <li{{ item.attributes }}>{{ item|slice(0, 2) }}</li>

    Hope this help!

    Thank you.

Production build 0.71.5 2024