-
AuthorPosts
-
August 8, 2017 at 9:43 am #835750
Hi Kriesi team
Is it possible to add a ‘search’ to main navigation when using the main menu on the left as per the Enfold photography demo?
Cheers
PatrickAugust 8, 2017 at 2:11 pm #835839i just switched my layout to left main menu – and i found a hook we can use for that in helper-main-menu.php
this to child-theme functions.php
add_filter( 'ava_inside_main_menu', 'avia_append_search_nav_mod'); function avia_append_search_nav_mod() { global $avia_config; ob_start(); get_search_form(); $form = htmlspecialchars(ob_get_clean()) ; $items .= '<div id="menu-item-search"> <a href="?s=" data-avia-search-tooltip="'.$form.'" '.av_icon_string('search').'><span class="avia_hidden_link_text">'.__('Search','avia_framework').'</span></a> </div>'; echo $items; }
and that to quick css ( play a bit with the values):#top #menu-item-search { margin-left: 15%; width: 70%; z-index: 100; } .avia-search-tooltip.avia-tt { left: 110px !important; position: relative; top: 5px !important; } .avia-search-tooltip .avia-arrow-wrap { left: 20px !important; right: inherit }
looks this way – click to enlarge:
- This reply was modified 7 years, 3 months ago by Guenni007.
August 8, 2017 at 2:12 pm #835842i’ve been looking for a hook into the main-menu itself now – but that was my first view attempt.
August 8, 2017 at 3:04 pm #835870ok – i think this is the propper version of doing it:
this to funktions.php of your child-theme:
add_filter( 'wp_nav_menu_items', 'avia_append_search_nav', 10, 2 ); function avia_append_search_nav ( $items, $args ) { if ((is_object($args) && $args->theme_location == 'avia') || (is_string($args) && $args = "fallback_menu")) { global $avia_config; ob_start(); get_search_form(); $form = htmlspecialchars(ob_get_clean()) ; $items .= '<li id="menu-item-search" class="noMobile menu-item menu-item-search-dropdown menu-item-avia-special"> <a href="?s=" data-avia-search-tooltip="'.$form.'" '.av_icon_string('search').'><span class="avia_hidden_link_text">'.__('Search','avia_framework').'</span></a> </li>'; } return $items; }
if you like you can style it afterwards with quick css !
and !!! you have to unstick the “Sticky Sidebar menu” – because the ajax searchresult preview is sometimes longer – so you have to be able to scroll down
August 9, 2017 at 6:36 am #836155Hi,
Thanks a lot for the input @guenni007, much appreciated as usual. Did you have any luck with the suggestions @peeej77?
Best regards,
RikardAugust 9, 2017 at 7:28 am #836194Hi guys
@guenni007 thank you for your elegant & speedy work. From the looks of your example here https://webers-testseite.de/ this is exactly what I am looking for!I’m working on this project in my spare time so will add the .php script and style the CSS in the next couple of days (Australia time) and keep you posted. I’m super confident in what @guenni007 has provided – top work.
@Rikard – the support on this forum is great. Keep up the good work. -
AuthorPosts
- You must be logged in to reply to this topic.