-
Author
Tagged: top menu, ajax search pro
-
May 28, 2017 at 05:41 #162839cd690767Participant
Hi,
You told me earlier how to add a search to the top menu with the code below:
function kleo_search_menu_item( $items, $args ) {
if ( sq_option( ‘ajax_search’, 1 ) == ‘logged_in’ && ! is_user_logged_in() ) {
return $items;}
$location = sq_option( ‘menu_search_location’, ‘primary’ );
if ( $args->theme_location == ‘top’ ) {
$form = kleo_get_search_menu_item();
$items .= ” . $form . ”; }
return $items;}}
Now I’ve installed Ajax Search Pro and for some reason the search in the top menu isn’t executing the search from ajax search pro search, it is still executing the KLEO search. Can you tell me where I need to add the ASP shortcode (echo do_shortcode(‘[wpdreams_ajaxsearchpro id=1]’);) to the code shown above?
Thanks
Cathy
May 29, 2017 at 17:28 #162898LauraModeratorHello, will assign the ticket to a higher support level who can help and advise you in your query.
Thanks! ?Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
May 31, 2017 at 19:10 #163128RaduModeratorHi,
You can try to edit that function like that, give a try
COPY CODEfunction kleo_search_menu_item( $items, $args ) { if ( sq_option( 'ajax_search', 1 ) == 'logged_in' && ! is_user_logged_in() ) { return $items; } $location = sq_option( 'menu_search_location’, 'primary' ); if ( $args->theme_location == 'top' ) { $form = echo do_shortcode('[wpdreams_ajaxsearchpro id=1]) ); $items .= " . $form . "; } return $items;} }
Let me know
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 1, 2017 at 00:05 #163171cd690767ParticipantHi Radu,
Thanks for the help, but unfortunately it doesn’t work- I get the error shown below:
Parse error: syntax error, unexpected ‘primary’ (T_STRING) in /home/XXXXX/public_html/wp-content/themes/kleo-child/functions.php on line 101
line 101 is:
$location = sq_option( ‘menu_search_location’, ‘primary’ );I changed “primary” to “top” but got the same error.
Regards,
CathyJune 5, 2017 at 15:12 #163401RaduModeratorHi,
Try again using this code instead of previous one.
COPY CODEif ( ! function_exists( 'kleo_search_menu_item' ) ) { /** * Add search to menu * * @param string $items * @param object $args * * @return string */ function kleo_search_menu_item( $items, $args ) { if ( sq_option( 'ajax_search', 1 ) == 'logged_in' && ! is_user_logged_in() ) { return $items; } $location = sq_option( 'menu_search_location', 'primary' ); if ( $args->theme_location == $location ) { $form = echo do_shortcode('[wpdreams_ajaxsearchpro id=1]') ); $items .= '<li id="nav-menu-item-search" class="menu-item kleo-search-nav">' . $form . '</li>'; } return $items; } }
Let me know
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 6, 2017 at 00:43 #163479cd690767ParticipantHi Radu,
Thanks for the continued help but this snippet doesn’t work either. I get this error:
Parse error: syntax error, unexpected ‘;’ in /home/XXXXX/public_html/wp-content/themes/kleo-child/functions.php on line 97Line 97 is:
if ( sq_option( ‘ajax_search’, 1 ) == ‘logged_in’ && ! is_user_logged_in() ) {I tried removing each ; but that didn’t work. Removing both ; gave an error for the !.
If this won’t work let me know and I’ll take the search out of the top menu.
Regards,
CathyJune 7, 2017 at 18:45 #163657RaduModeratorHi,
Replace with this one : https://pastebin.com/raw/RPANuCA6
Let me know
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 17, 2017 at 04:05 #164495cd690767ParticipantHi Radu,
I thought I replied several days ago; sorry for the delay! This snippet also doesn’t work- it gives the following error:
Parse error: syntax error, unexpected ‘echo’ (T_ECHO) in /home/XXXXX/public_html/wp-content/themes/kleo-child/functions.php on line 103line 103 is:
$form = echo do_shortcode(‘[wpdreams_ajaxsearchpro id=1])’);If I remove “echo” then there is no error, but then if I enter a search term in the search form in the top menu, the search form disappears from the menu after I hit enter.
Any other suggestions?
Thanks
CathyJune 20, 2017 at 15:42 #164728RaduModeratorI see,
Please create a page in that you will paste only this shortcode [wpdreams_ajaxsearchpro id=1]
to see exactly what is rendered or give me the admin credentials to take a closer look.
cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 20, 2017 at 23:10 #164789cd690767ParticipantHi Radu,
Sorry this keeps causing problems; feel free to tell me you don’t want to worry about it anymore.
When I put the ASP shortcode in a page, I get the same output as in the ASP widget- the search results are styled according to settings of ASP and displayed beneath the search form. It all seems to work like it should.
With the kleo search in the top menu, when I type in a search term I also get ajax results displayed beneath the search form until I hit enter, at which point some results are displayed on a page (but they are not in the same format as they are in the ajax display).
Regards,
CathyJune 23, 2017 at 15:56 #165010RaduModeratorHi,
If those can be combined easy I can help you but I need to see it’s this can be made easy or not.
When I access your website it’s displayed coming soon page and i cannot see how the ASP shortcode.
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJune 27, 2017 at 17:12 #165391RaduModeratorI saw how it behaves… but I don’t know if this can be easily integrated, please provide and FTP credentials to see it’s an easy way to do this.
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJuly 4, 2017 at 16:26 #166247RaduModeratorHi,
FTP works but the admin credentials are incorrect
Let me know
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJuly 12, 2017 at 17:33 #167172RaduModeratorHi,
Fixed! Check the search icon from the menu
I’ve replaced code with this one in child theme functions.php file
COPY CODEif ( ! function_exists( 'kleo_get_search_menu_item' ) ) { function kleo_get_search_menu_item() { $context = sq_option( 'search_context', '' ); if ( is_array( $context ) ) { $context = implode( ',', $context ); } //Defaults $action = home_url( '/' ); $hidden = ''; $input_name = 's'; if ( function_exists( 'bp_is_active' ) && $context == 'members' ) { //Buddypress members form link $action = bp_get_members_directory_permalink(); } elseif ( function_exists( 'bp_is_active' ) && bp_is_active( 'groups' ) && $context == 'groups' ) { //Buddypress group directory link $action = bp_get_groups_directory_permalink(); } elseif ( class_exists( 'bbPress' ) && $context == 'forum' ) { $action = bbp_get_search_url(); $input_name = 'bbp_search'; } elseif ( $context == 'product' ) { $hidden .= '<input type="hidden" name="post_type" value="product">'; $action = home_url( '/' ) . '?post_type=product'; } ob_start(); ?> <a class="search-trigger" href="#"><i class="icon icon-search"></i></a> <div class="kleo-search-wrap searchHidden" id="ajax_search_container"> <?php echo do_shortcode('[wpdreams_ajaxsearchpro id=1]'); ?> <div class="kleo_ajax_results"></div> </div> <?php $form = ob_get_clean(); return $form; } }
Also, I've added this CSS in quick css area to make a little space between input search form and the container edges.
COPY CODE#header div#ajax_search_container { padding: 10px 10px; }
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Ticket solutionJuly 14, 2017 at 17:27 #167425RaduModeratorAdd this function
COPY CODEif ( ! function_exists( 'kleo_search_menu_item' ) ) { /** * Add search to menu * * @param string $items * @param object $args * * @return string */ function kleo_search_menu_item( $items, $args ) { if ( sq_option( 'ajax_search', 1 ) == 'logged_in' && ! is_user_logged_in() ) { return $items; } //$location = sq_option( 'menu_search_location', 'primary' ); if ( $args->theme_location == 'top' ) { $form = kleo_get_search_menu_item(); $items .= '<li id="nav-menu-item-search" class="menu-item kleo-search-nav">' . $form . '</li>'; } return $items; } }
The function needs to be pasted in wp-content/themes/kleo-child/functions.php
NOTE : Child theme needs to be installed and activated.
Tested on my local install the seatch item will go to topbar.
Please leave us a review on themeforest about your experience and give us 5* if you think the support it’s high quality.
Have a nice day
Regards
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJuly 18, 2017 at 18:36 #167837RaduModeratorYou’re welcome
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘Bugs & Issues’ is closed to new topics and replies.