This topic has 20 replies, 3 voices, and was last updated 7 years by Radu.

  • Author
  • #162839
     cd690767
    Participant

    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

    #162898
     Laura
    Moderator

    Hello, 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 solution

    Laura 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 🙂

    #163128
     Radu
    Moderator

    Hi,

    You can try to edit that function like that, give a try

    COPY CODE
    
    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 = 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 solution
    #163171
     cd690767
    Participant

    Hi 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,
    Cathy

    #163401
     Radu
    Moderator

    Hi,

    Try again using this code instead of previous one.

    COPY CODE
    
    if ( ! 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 solution
    #163479
     cd690767
    Participant

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

    Line 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,
    Cathy

    #163657
     Radu
    Moderator

    Hi,

    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 solution
    #164495
     cd690767
    Participant

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

    line 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
    Cathy

    #164728
     Radu
    Moderator

    I 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 solution
    #164789
     cd690767
    Participant

    Hi 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,
    Cathy

    #165010
     Radu
    Moderator

    Hi,

    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
    R

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #165060
     cd690767
    Participant
    This reply has been set as private.
    #165391
     Radu
    Moderator

    I 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 solution
    #165486
     cd690767
    Participant
    This reply has been set as private.
    #166247
     Radu
    Moderator

    Hi,

    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 solution
    #166982
     cd690767
    Participant
    This reply has been set as private.
    #167172
     Radu
    Moderator

    Hi,

    Fixed! Check the search icon from the menu

    I’ve replaced code with this one in child theme functions.php file

    COPY CODE
    
    
    if ( ! 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 solution
    #167252
     cd690767
    Participant
    This reply has been set as private.
    #167425
     Radu
    Moderator

    Add this function

    COPY CODE
    
    if ( ! 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 solution
    #167746
     cd690767
    Participant
    This reply has been set as private.
    #167837
     Radu
    Moderator

    You’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
Viewing 21 posts - 1 through 21 (of 21 total)

The forum ‘Bugs & Issues’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?