Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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

    #1320246

    Hey 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,
    Ismael

    #1320254

    Hi Ismael,
    thank you for your feedback. I’ve just add the snippet in function.php but it doesnt’work.
    The function.php launches this alert :(
    Schermata-2021-09-09-alle-13-06-52

    #1320335

    Hi,

    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,
    Ismael

    #1320388

    Hi 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!
    federica

    #1320474

    Hi,

    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,
    Ismael

    #1320679

    Hello 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
    Federica

    #1320840

    Hi,

    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,
    Ismael

    #1320955

    Hi 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!!

    #1321121

    Hi,

    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,
    Ismael

    #1321353

    Ismael! Thank you! It works perfect!!!!!

    #1321489

    Hi,

    Great, I’m glad that Ismael could help you out. Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.