Hello,
I am working with the Craft theme.
I would like to remove the search icon in the upper left hand corner and replace it with a search box.
I’ve attached a screen shot with markups
My page address is:
https://aerbzf-hp.myshopify.com/
I’m familier with editing the code, but just need to know what files to edit, and the needed code.
Thank You,
Kent
suyash1
December 26, 2024, 4:52pm
2
@lakeside-molds - check if you have header.liquid or header-group.liquid file, you will need to copy search modal code in the place where you want search to appear. I recommend to create copy of the active theme and make changes to it. Once it works then you can make it live
Hello,
I have a header.liquid file.
I don’t have a header-group.liquid file, however I do have a header-group.json file.
Yes, I’m working with a sandbox version of the page.
Thanks,
Kent
suyash1
December 26, 2024, 5:05pm
4
@lakeside-molds - check search modal in header file, check what file name do you have in json file
Here is a portion of the code from the header file ( I hope I included the section you are looking for )
I will reply in a separate reply with your question on the json file
{%- liquid
if section.settings.menu != blank
render 'header-drawer'
endif
if section.settings.logo_position == ‘top-center’ or section.settings.menu == blank
render ‘header-search’, input_id: ‘Search-In-Modal-1’
endif
-%}
{%- if section.settings.logo_position != ‘middle-center’ -%}
{%- if request.page_type == ‘index’ -%}
{%- endif -%}
{%- endif -%}
{%- liquid
if section.settings.menu != blank
if section.settings.menu_type_desktop == ‘dropdown’
render ‘header-dropdown-menu’
elsif section.settings.menu_type_desktop != ‘drawer’
render ‘header-mega-menu’
endif
endif
%}
suyash1
December 26, 2024, 5:16pm
6
@lakeside-molds check this file ---- header-search
Here is my code from the json file
{
“name”: “t:sections.header.name”,
“type”: “header”,
“sections”: {
“header”: {
“type”: “header”,
“settings”: {
“logo_position”: “top-center”,
“menu”: “main-menu”,
“menu_type_desktop”: “drawer”,
“sticky_header_type”: “always”,
“show_line_separator”: true,
“color_scheme”: “scheme-1”,
“menu_color_scheme”: “scheme-1”,
“enable_country_selector”: true,
“enable_language_selector”: true,
“enable_customer_avatar”: true,
“mobile_logo_position”: “center”,
“margin_bottom”: 0,
“padding_top”: 20,
“padding_bottom”: 20
}
},
“announcement-bar”: {
“type”: “announcement-bar”,
“blocks”: {
“announcement-bar-0”: {
“type”: “announcement”,
“settings”: {
“text”: “- Welcome to Lakeside Molds Online Store - ( Tel: 701-520-1872 )”,
“link”: “”
}
}
},
“block_order”: [
“announcement-bar-0”
],
“settings”: {
“color_scheme”: “scheme-4”,
“show_line_separator”: true,
“show_social”: false,
“auto_rotate”: false,
“change_slides_speed”: 5,
“enable_country_selector”: false,
“enable_language_selector”: false
}
}
},
“order”: [
“header”,
“announcement-bar”
]
}
suyash1
December 26, 2024, 5:18pm
8
@lakeside-molds check this file ---- header-search
Here is my header-search
{% comment %}
Renders a header search modal. Should be used with ‘header.liquid’
Accepts:
input_id: {String} Id for the search input element (required)
Usage:
{% render ‘header-search’, input_id: ‘My-Id’%}
{% endcomment %}
{{- 'icon-search.svg' | inline_asset_content -}}
{{- 'icon-close.svg' | inline_asset_content -}}
{%- if settings.predictive_search_enabled -%}
{%- else -%}
{%- endif -%}
{{ 'general.search.search' | t }}
{{- 'icon-reset.svg' | inline_asset_content -}}
{{- 'icon-search.svg' | inline_asset_content -}}
{%- if settings.predictive_search_enabled -%}
{%- render 'loading-spinner', class: 'predictive-search__loading-state' -%}
{%- endif -%}
{%- if settings.predictive_search_enabled -%}
{%- else -%}
{%- endif -%}
{{- 'icon-close.svg' | inline_asset_content -}}
This is my header-search.liquid
{% comment %}
Renders a header search modal. Should be used with ‘header.liquid’
Accepts:
input_id: {String} Id for the search input element (required)
Usage:
{% render ‘header-search’, input_id: ‘My-Id’%}
{% endcomment %}
{{- 'icon-search.svg' | inline_asset_content -}}
{{- 'icon-close.svg' | inline_asset_content -}}
{%- if settings.predictive_search_enabled -%}
{%- else -%}
{%- endif -%}
{{ 'general.search.search' | t }}
{{- 'icon-reset.svg' | inline_asset_content -}}
{{- 'icon-search.svg' | inline_asset_content -}}
{%- if settings.predictive_search_enabled -%}
{%- render 'loading-spinner', class: 'predictive-search__loading-state' -%}
{%- endif -%}
{%- if settings.predictive_search_enabled -%}
{%- else -%}
{%- endif -%}
{{- 'icon-close.svg' | inline_asset_content -}}
suyash1
December 26, 2024, 5:29pm
11
@lakeside-molds - this is the search code, try this, I have removed few if conditions to make it work, please check and make necessary updates
Hello,
I placed that code into my header-search.liquid file. ( is that correct? )
That didn’t appear to make any changes to the page.
Here is a copy of the header-search.liquid file after I inserted your code into it.
{% comment %}
Renders a header search modal. Should be used with ‘header.liquid’
Accepts:
input_id: {String} Id for the search input element (required)
Usage:
{% render ‘header-search’, input_id: ‘My-Id’%}
{% endcomment %}
{{- 'icon-search.svg' | inline_asset_content -}}
{{- 'icon-close.svg' | inline_asset_content -}}
{{ 'general.search.search' | t }}
{{- 'icon-reset.svg' | inline_asset_content -}}
{{- 'icon-search.svg' | inline_asset_content -}}
{%- render 'loading-spinner', class: 'predictive-search__loading-state' -%}
<button
type=“button”
class=“search-modal__close-button modal__close-button link link–text focus-inset”
aria-label=“{{ ‘accessibility.close’ | t }}”
{{- 'icon-close.svg' | inline_asset_content -}}
Hello,
I went back and replaced the header-search.liquid file with only your code ( in other words I removed the code that was above and below it ) and that seemed to work. The only glitch is that there are ( 2 ) search boxes now. If we could get rid of the one on the right side, and then we should be good to go. ( see screen shot )
Also I’m wondering if the width of the box on the left was just a little narrower it may line up in the center vertically?
suyash1
December 27, 2024, 2:27am
14
@lakeside-molds - to hide search on right, please add this css to the very end of your base.css file and check,
Shopify Admin → Online Store ->Theme → Edit code → base.css
.header__icons .search-modal__content{display:none; visibility:hidden;}
to make it center
@media screen and (min-width: 750px) {
.search-modal__content {grid-area: left-icons;}
}
Yes, that did the trick!!! Thank You very Much!
I will drop you an email.
Thanks again…
Kent
I just had one last item… Not sure if this was something that just happened with these recent code changes or if it was like this before… but I just noticed that in order to click on the word “menu” in the upper left hand corner that the only letter that has the clickable link is the letter “M” on the word menu… so in other words you have to have the pointer right on the perfect spot to get the menu to activate.
suyash1
December 27, 2024, 3:20am
17
@lakeside-molds – add margin to it and check
@media screen and (min-width: 750px) {
.search-modal__content {grid-area: left-icons; margin-left: 40px;}
}
Yes, that did the trick. Thank You !
suyash1
December 27, 2024, 3:37am
19
@lakeside-molds great, do let me know if you need any more updates, I have replied on email.