Tagged: mobile menu, search box
-
AuthorPosts
-
September 8, 2021 at 4:24 pm #1320113
Hi,
I’m trying to integrate the search field into the mobile menu but it doesn’t work.
I followed this thread:
https://kriesi.at/support/topic/search-box-in-mobile-menu-2/#post-1278540
but there’s not the right snippet for who uses an alternate menu.
Could you please show it?
PD: The client output: https://ibb.co/6Jnn5Yf
Thank you!
Federica- This topic was modified 3 years, 2 months ago by federica_alice.
September 9, 2021 at 12:31 pm #1320246Hey Federica,
Thank you for the inquiry.
Did you add the following snippet in the functions.php file? This should create a search field within the mobile menu container when the mobile menu icon is clicked.
// https://kriesi.at/support/topic/search-box-in-mobile-menu-2/#post-1277234
Best regards,
IsmaelSeptember 9, 2021 at 1:09 pm #1320254September 10, 2021 at 6:43 am #1320335Hi,
Thank you for the info.
According to the error in the screenshot, the avf_add_search function is already declared or has been duplicated. You have to remove the previous avf_add_search function from the functions.php file.
Best regards,
IsmaelSeptember 10, 2021 at 11:50 am #1320388Hi Ismael,
I try the the snippet below
// https://kriesi.at/support/topic/search-box-in-mobile-menu-2/#post-1277234
but doesn’t work for me.
My menu is an alternate menu. Could be this the cause?
Thank you!
federicaSeptember 11, 2021 at 2:04 am #1320474Hi,
The avf_add_search function is already added in the functions.php file, so the error occurs because you are trying to duplicate the function. You have to remove the previous avf_add_search function first. After removing any instances of the avf_add_search function from the functions.php file, try to add the following snippet.
// https://kriesi.at/support/topic/search-box-in-mobile-menu-2/#post-1277234
Best regards,
IsmaelSeptember 13, 2021 at 9:53 am #1320679Hello Ismael,
yes, understand. I removed the function and add the snippet that it doesn’t work for me!
I’ve tried it many times :)
Thank you
FedericaSeptember 14, 2021 at 6:31 am #1320840Hi,
We edited the functions.php file and adjusted the script a bit for the new mobile menu.
// add search bar to mobile menu function ava_custom_script_mod_search_mobile() { ?> <script> (function($) { $(document).ready(function() { var page = window.location.href; var search = '<form action="'+page+'" method="get" class=""><div><input type="submit" value="?" id="searchsubmit" class="button avia-font-entypo-fontello"><input type="text" id="s" name="s" value="" placeholder="Search"></div></form>'; $('.av-burger-menu-main a').on('click', function() { if($(".av-mobile-search").find('form').length == 1) return; setTimeout(() => { $("<div class='av-mobile-search'>" + search + "</div>").prependTo('#av-burger-menu-ul'); }, 300); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'ava_custom_script_mod_search_mobile', 10000);
The search bar is now added above the mobile menu items but it will require a bit of css modification. You can start with the following.
.av-mobile-search div { position: relative; }
Best regards,
IsmaelSeptember 14, 2021 at 7:59 pm #1320955Hi Ismael,
it works like a charm! Thank you!
I add some css:
.av-mobile-search div {
position: relative;
width: 90%;
margin-left:20px !important;
margin-right:20px !important;
}.av-mobile-search input[type=’text’] {
background-color:#ffffff !important;
padding:20px !important;
font-size:20px !important;
font-family:’libre-baskerville-1′,’HelveticaNeue’,’Helvetica Neue’,’Helvetica-Neue’ !important;
font-style:oblique !important;
}.av-mobile-search input[type=’submit’] {
color: #dc5b24!important;
background-color: #ffffff !important;
font-size:28px !important;}
.av-mobile-search #searchsubmit, .ajax_load {
width: 60px !important;
height:62px !important;
}But I can’t move it between ‘ DOMANE&RISPOSTE’ e ‘CHI SIAMO’ just like this https://ibb.co/6Jnn5Yf
Could you please suggest me the right code to do it?Thank. you very much!!
- This reply was modified 3 years, 2 months ago by federica_alice.
September 16, 2021 at 4:21 am #1321121Hi,
Thank you for following up. Glad to know that the modification is working.
To move the search form before the CHI SIAMO menu item, try to replace the script with the following.
// add search bar to mobile menu function ava_custom_script_mod_search_mobile() { ?> <script> (function($) { $(document).ready(function() { var page = window.location.href; var search = '<form action="'+page+'" method="get" class=""><div><input type="submit" value="?" id="searchsubmit" class="button avia-font-entypo-fontello"><input type="text" id="s" name="s" value="" placeholder="Search"></div></form>'; $('.av-burger-menu-main a').on('click', function() { if($(".av-mobile-search").find('form').length == 1) return; setTimeout(() => { $("<li class='av-mobile-search av-active-burger-items'>" + search + "</div>").insertAfter('.menu-item-178580'); }, 300); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'ava_custom_script_mod_search_mobile', 10000);
Best regards,
IsmaelSeptember 17, 2021 at 10:21 am #1321353Ismael! Thank you! It works perfect!!!!!
September 19, 2021 at 6:15 am #1321489 -
AuthorPosts
- You must be logged in to reply to this topic.