How can I add a search bar on collection pages on Refresh theme?
I have a search button that then opens to a search bar but I would like there to be a permanent search bar present on collection pages
How can I add a search bar on collection pages on Refresh theme?
I have a search button that then opens to a search bar but I would like there to be a permanent search bar present on collection pages
Hi @jhghidossi ,
We can try to add the existing search section to your Collection page. Just follow the instructions below.
To make the search section visible in Theme editor:
,"presets": [
{
"name": "Search section"
}
]
Please see image for placement
Go to your Theme Editor, just hit Customize theme, in your right hand top corner.
Go to your Collection page by changing home page to Collection > Default Collection.
Then click Add a section, find the Search section.
Here is the search section looks like:
Hi @made4Uo ,
Is there a way to position it in the above the header and move the categories below?
Also remove the Search title and edit the colours?
Kind Regards.
{{ 'template-collection.css' | asset_url | stylesheet_tag }}
{{ 'component-card.css' | asset_url | stylesheet_tag }}
{{ 'component-price.css' | asset_url | stylesheet_tag }}
{%- if section.settings.enable_filtering or section.settings.enable_sorting -%}
{{ 'component-facets.css' | asset_url | stylesheet_tag }}
{%- endif -%}
{%- liquid
assign sort_by = search.sort_by | default: search.default_sort_by
assign terms = search.terms | escape
assign search_url = '?q=' | append: terms | append: '&options%5Bprefix%5D=last&sort_by=' | append: sort_by
-%}
{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}
@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}
{%- if search.performed -%}
# {{ 'templates.search.title' | t }}
{%- else -%}
# {{ 'general.search.search' | t }}
{%- endif -%}
{%- if settings.predictive_search_enabled -%}
{%- endif -%}
{%- if search.performed -%}
{%- unless section.settings.enable_filtering or section.settings.enable_sorting -%}
{%- if search.results_count > 0 -%}
{{ 'templates.search.results_with_count_and_term' | t: terms: search.terms, count: search.results_count }}
{%- endif -%}
{%- endunless -%}
{%- if search.results_count == 0 and search.filters == empty -%}
{{ 'templates.search.no_results' | t: terms: search.terms }}
{%- endif -%}
{%- endif -%}
{%- if search.performed -%}
{%- if section.settings.enable_sorting and section.settings.filter_type == 'vertical' and search.filters != empty -%}
{%- endif -%}
{%- endif -%}
{% schema %}
{
"name": "t:sections.main-search.name",
"tag": "section",
"class": "section",
"settings": [
{
"type": "range",
"id": "columns_desktop",
"min": 1,
"max": 5,
"step": 1,
"default": 4,
"label": "t:sections.main-search.settings.columns_desktop.label"
},
{
"type": "header",
"content": "t:sections.main-search.settings.header__1.content"
},
{
"type": "select",
"id": "image_ratio",
"options": [
{
"value": "adapt",
"label": "t:sections.main-search.settings.image_ratio.options__1.label"
},
{
"value": "portrait",
"label": "t:sections.main-search.settings.image_ratio.options__2.label"
},
{
"value": "square",
"label": "t:sections.main-search.settings.image_ratio.options__3.label"
}
],
"default": "adapt",
"label": "t:sections.main-search.settings.image_ratio.label"
},
{
"type": "checkbox",
"id": "show_secondary_image",
"default": false,
"label": "t:sections.main-search.settings.show_secondary_image.label"
},
{
"type": "checkbox",
"id": "show_vendor",
"default": false,
"label": "t:sections.main-search.settings.show_vendor.label"
},
{
"type": "checkbox",
"id": "show_rating",
"default": false,
"label": "t:sections.main-search.settings.show_rating.label",
"info": "t:sections.main-search.settings.show_rating.info"
},
{
"type": "header",
"content": "t:sections.main-collection-product-grid.settings.header__1.content"
},
{
"type": "checkbox",
"id": "enable_filtering",
"default": true,
"label": "t:sections.main-collection-product-grid.settings.enable_filtering.label",
"info": "t:sections.main-collection-product-grid.settings.enable_filtering.info"
},
{
"type": "select",
"id": "filter_type",
"options": [
{
"value": "horizontal",
"label": "t:sections.main-collection-product-grid.settings.filter_type.options__1.label"
},
{
"value": "vertical",
"label": "t:sections.main-collection-product-grid.settings.filter_type.options__2.label"
},
{
"value": "drawer",
"label": "t:sections.main-collection-product-grid.settings.filter_type.options__3.label"
}
],
"default": "horizontal",
"label": "t:sections.main-collection-product-grid.settings.filter_type.label",
"info": "t:sections.main-collection-product-grid.settings.filter_type.info"
},
{
"type": "checkbox",
"id": "enable_sorting",
"default": true,
"label": "t:sections.main-collection-product-grid.settings.enable_sorting.label"
},
{
"type": "header",
"content": "t:sections.main-search.settings.header__2.content",
"info": "t:sections.main-search.settings.header__2.info"
},
{
"type": "checkbox",
"id": "article_show_date",
"default": true,
"label": "t:sections.main-search.settings.article_show_date.label"
},
{
"type": "checkbox",
"id": "article_show_author",
"default": false,
"label": "t:sections.main-search.settings.article_show_author.label"
},
{
"type": "header",
"content": "t:sections.main-search.settings.header_mobile.content"
},
{
"type": "select",
"id": "columns_mobile",
"default": "2",
"label": "t:sections.main-search.settings.columns_mobile.label",
"options": [
{
"value": "1",
"label": "t:sections.main-search.settings.columns_mobile.options__1.label"
},
{
"value": "2",
"label": "t:sections.main-search.settings.columns_mobile.options__2.label"
}
]
},
{
"type": "header",
"content": "t:sections.all.padding.section_padding_heading"
},
{
"type": "range",
"id": "padding_top",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_top",
"default": 36
},
{
"type": "range",
"id": "padding_bottom",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_bottom",
"default": 36
}
]
,"presets": [
{
"name": "Search section"
}
]
}
{% endschema %}
Thanks for this @made4Uo , Please is there a way to change the search label name in the search bar to a personalised own, thanks