Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: search result 500 #54

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions theme/partials/components/search-results.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,28 @@
class="search-results__category-list-wrapper col"
col-xs-12 col-sm-12 col-md-3
>
{% set item_categories = [] %}
{% for item in items %}
{% set category = item.categories[0] %}
{% set categoryExists = item_categories|filter((c) => c.square_online_id == category.square_online_id) %}
{% if category.square_online_id and categoryExists == false %}
{% set item_categories = item_categories|merge([category]) %}
{% endif %}
{% endfor %}
<p class="search-results__category-list-header">
{% if query is not defined %}
{% if (query is not defined) and (item_categories is not empty) %}
{{ 'components.search.suggested_searches'|localize }}
{% else %}
{% elseif query is defined %}
{{ 'components.search.top_results'|localize }}
{% endif %}
</p>
<ul class="search-results__category-list">
{% set item_categories = [] %}
{% for item in items %}
{% set category = item.categories[0] %}
{% if category.square_online_id not in item_categories %}
{% set item_categories = item_categories|merge([category.square_online_id]) %}
<li class="search-results__category-list-item">
<a class="search-results__category-link" href="{{ category_link(category.square_online_id) }}">
{{ category.name }}
</a>
</li>
{% endif %}
{% for category in item_categories %}
<li class="search-results__category-list-item">
<a class="search-results__category-link" href="{{ category_link(category.square_online_id) }}">
{{ category.name }}
</a>
</li>
{% endfor %}
</ul>
</div>
Expand Down