Helping you Build Your Own Social Network!

Faster, better and easier!

Creating a Unified Search From Different Search Bar

(46 posts) (4 voices)
  • Started 1 year ago by gregfielding
  • Latest reply from labedford

Tags:

No tags yet.


  1. Brajesh,

    I'm excited about the unified search, but am not sure what the best way is to use it on my site. I'm using a theme that, out of the box, came with 2 search bars on the front page. One was the default (members-groups-etc) BP search, and the other simply said "search" and functions to search for blog posts on the main site only.

    I thought having so many search options was confusing, so I deleted the drop-down search from the theme.

    So, is there a way to perform the unified search using this different search form?

    Also, will this search for posts on member blogs?

    Thanks!

    Posted 1 year ago #
  2. Hi Greg
    checked your site. It will not work with your current search box, as the current search box on your site searches only for the blog posts, and is wordpress search from not the buddypress.
    Bu by changing one line in the form action, you can make it work with the unified search
    Change the form action to
    <?php echo bp_search_form_action() ?>
    and then you can apply the codes for unified search.

    The unified search currently will allow you to list results from all the active components(members/groups/forums/blogs/blog posts). It does not searches for the blog posts of sub blogs, but only for the main blog as it is happening on your site.

    Hope it helps.
    Thanks
    Brajesh

    Posted 1 year ago #
  3. So change this line:
    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">

    To:
    <form method="get" id="searchform" action="<?php echo bp_search_form_action() ?>/">

    ?

    Then skip step 1 and 2 in your instructions?

    Posted 1 year ago #
  4. hi Greg, you will not need step 1, but step 2 is required.

    PS: now I may be away for a few hours.

    Posted 1 year ago #
  5. I think I've almost got it working. The only problem I have is that the results are wrong.

    Under Members Results, it shows EVERY member. Ditto for Blogs and Forums...all blogs and forums.

    Also, it shows a search result in the old format at the bottom...I'm guessing it's a problem with the fix for my other search box.

    I'll include that code below.

    It does, however, get the "Blog Search" part right. :)

    Posted 1 year ago #
  6. My searchform.php:

    <?php include (TEMPLATEPATH . '/library/options/options.php'); ?>
    <?php if($bp_existed == 'true') { ?>
    <?php do_action( 'bp_before_blog_search_form' ) ?>
    <?php } ?>
    <form method="get" id="searchform" action="<?php echo bp_search_form_action() ?>/">
    <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" size="32" />
    <input type="submit" id="searchsubmit" value="<?php _e( 'Search', 'bp-daily' ) ?>" />
    <?php if($bp_existed == 'true') { ?>
    <?php do_action( 'bp_blog_search_form' ) ?>
    <?php } ?>
    </form>
    <?php if($bp_existed == 'true') { ?>
    <?php do_action( 'bp_after_blog_search_form' ) ?>
    <?php } ?>

    Posted 1 year ago #
  7. AHHH! Big Problem....

    This got added to the functions.php of EVERY THEME IN THE COMMUNITY...PUTTING WHITE SCREENS ON EVERY SITE!

    <?php
    }

    //Hook Blogs results to search page if blogs comonent is active
    if(bp_is_active( 'blogs' ))
    add_action("advance-search","bpmag_show_blogs_search",10);

    //modify the query string with the search term
    function bpmag_global_search_qs(){
    return "search_terms=".$_REQUEST['search-terms'];
    }

    function bpmag_is_advance_search(){
    global $bp;
    if($bp->current_component == BP_SEARCH_SLUG)
    return true;
    return false;
    }
    ?>

    Posted 1 year ago #
  8. Here's the error:

    Parse error: syntax error, unexpected '}' in /home/housings/public_html/wp-content/themes/pundit/functions.php on line 229

    Posted 1 year ago #
  9. hi Greg
    Have you copied the functions from the attached zip file(The tutorial functions should not be directly copied, if you are copying from tutorial page, there is an <> button above the each code block, you should use that to copy code).
    If you are copying from the attached zip file, just make sure that the begining and endingtags are correct in your functions.php and It will work.

    In the above code block, the first line "}" is not required, that may be the reason of your trouble.

    Please let me know which approach you used.
    Thanks
    Brajesh

    Posted 1 year ago #
  10. Brajesh,

    The "}"s are in your download code.

    I copied and pasted the download functions.php directly.

    Should I delete them? Just the top? Or all 3? And just from this section of code?

    Sorry to be such a pain...but I can't have errors on 300 blogs this morning :)

    Posted 1 year ago #
  11. hi Greg, the best thing will be can you post your code on pastebin.com, I can edit there and save making it far easier for you. What do you say ?

    Posted 1 year ago #
  12. http://pastebin.com/Qp4UhTNy

    It's your functions.php code with the "}" removed in the Blogs section...

    Just need the code to work without crashing all of the sub-blogs. :)

    Posted 1 year ago #
  13. hi Greg
    Try this one
    http://bpdev.pastebin.com/yJyZCVT6

    Posted 1 year ago #
  14. Isn't that the original code?

    The "}" on line 104 is what caused the syntax errors on all of our blogs.

    (It took me 3 hours last night to delete the bad code from all of my themes)

    Posted 1 year ago #
  15. Yes, That is original.
    What you posted here last night, was having a } at the top with the code snippet(Please check your post above) . So, At that moment It seemed the only culprit. When I checked all of your code now, then I found 3/4 "}" missing at the bottom lines, so just put them back.

    Try it with only one theme for now.
    And If possible, paste the whole functions.php(your original functions.php where you are including these functions) only that will give a final clue of the issues.
    Sorry for you troubles.

    Posted 1 year ago #
  16. No worries Brajesh...and I know you're busy with other projects and your own life! I'm just grateful for all of the great work that you are doing.

    Here's my entire functions.php along with the original downloaded code from you (minus step 1). This caused the syntax errors on all of my sub blogs.

    http://pastebin.com/hZRCmEmA

    Posted 1 year ago #
  17. hi Greg
    Thanks for the comment. I love to be here and help, and this is what you have paid me for :)
    And for me, there is only one thing currently what I do, coding all the time other than sleeping :D
    Now coming back to the topic.
    Your functions seems to be perfectly valid.
    Please check with this file, is the error still coming and if yes, then on which line.

    Posted 1 year ago #
  18. The error shows on all sub-blogs, as the code in comment 7 (above) get's inserted into the function.php file of each of those themes.

    I get error messages on all sub-blogs, with syntax errors referencing the first "}" in the code.

    I tried deleting the first "}" from the functions.php of the main blog (thinking it might solve the problem), but that sent the main site into whitescreen.

    Posted 1 year ago #
  19. hi again
    So, you are putting this in a single function.php(say of the parent theme) and It is getting inserted to all the other themes automatically, Am I right ?

    If that is the case, then your theme may be handling the things differently and I will advise putting it in bp-custom.php(haven't checked it with bp-custom.php though).

    Posted 1 year ago #
  20. Yes...I put in in the parent theme functions.php and it was inserted in every other blog.

    Should I try creating a functions.php in my child theme and adding it there?

    Posted 1 year ago #
  21. hi Greg
    yes, please try that. It seems to me, your theme uses functions.php in different way and inserts the code all over. Not sure why.

    Please try it with a specific child theme.

    Posted 1 year ago #
  22. Alright...I got it back working and it doesn't mess up my child themes. But the search results are still way off. I get every member, blog, and forum showing up in the results...
    Check it out...
    http://housingstorm.com/search/?s=utah

    Posted 1 year ago #
  23. hi Greg
    Just checked the results. The component search results are not correct.
    It simply means, the theme you are using is not supporting the standard buddypress convention.

    For example, please check "members/member-loop.php", does it have
    <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?>
    this line
    I mean "bp_ajax_querystring( 'members' ) "
    It seems the theme files do not use bp_ajax_querystring( ) in the loop, please check and let me know. Except the blog post search, nothing else is working there correctly.

    Posted 1 year ago #
  24. It does...right near the top.
    http://pastebin.com/3Y11DTPB

    Posted 1 year ago #
  25. Hiya Brajesh! Thank you very much for this!

    I installed Unified Search using the files you supplied and, after a bit of tweaking and customization, got everything working and looking just right.

    Well... almost just right.

    If you have the time, could you clue me in on the following?
    1 - How to exclude buttons in search results. ie: Friendship, Join/Leave group, Visit Blog, etc.
    2 - How to link Blog topic titles.
    3 - How to prevent WP pages labelled "Private" from showing up in search results.

    To see the search in action, and what I want to exclude from results, visit http://rspace.org and do a search for "help".

    Thanks a bunch! :-)

    EDIT: Greg's dilemma is urgent. I can wait for this 'cuz I'm on my way to the country until Sunday.
    EDIT #2: Forget about the "Private" pages question; I just realized they only show up when I'm logged in as admin. Oops...

    Posted 1 year ago #
  26. @Greg
    I am a little bit confused now. It has to do with the theme as far as can think of, because we are dealing with the theme specific functions. If the theme is handing bp_ajaxquerystring correctly, thet method will work perfectly.

    I checked again your site and seems you are still in the process of updting it, as the search results point me to members search result only.
    Please drop a message here again when your update is complete, I will be testing a few things again there

    @Patrick
    1.Do you really want to remove it. It is same as It comes on Buddypress search(the buttons for join etc is visible when you re logged in for each components original search, isn't it?)
    2. You will need to edit search-loop.php and change the line

    <h3 class="post-title"><?php the_title();?></h3>
    to
    h3 class="post-title"><a href="<?php the_permalink()"><?php the_title();?></a></h3>

    That should do it.
    Have a nice weekend :)

    Posted 1 year ago #
  27. So this is getting really weird...

    A few minutes after I sent you that link to search results to check out, my main site went whitescreen. No error messages...just nothing there. I quickly renamed my child theme functions.php to functions2.php and the site popped back up.
    I had nothing in this file before your code (the file didn't exist). Now, below your code is this code:
    http://pastebin.com/gmF7B6G2
    I'm going to try it in bp-custom.php...

    Posted 1 year ago #
  28. Just tried that and got this whitescreen error:
    Fatal error: Call to undefined function bp_is_active() in /home/housings/public_html/wp-content/plugins/bp-custom.php on line 63

    Line 63 my file is " if(bp_is_active( 'groups' ))"

    Posted 1 year ago #
  29. Greag
    I was just leaving from work. I am glad I show this message.
    It will not work in bp-custom.php (the functions which i used to add actions like bp_is_active()) needs to be caaled after buddypress has loaded while bp-custom.php loads before buddypress.

    Please avoid it for today, I will be back in next 4-5 hours and I guess when It will be tomorrow for you, will be checking that. the problem is you are using a premium theme which I don't have access to, so my hands are very limited with the things happening.
    The code works on bp-default/bp-mag theme, so the issues seems to be mostly pertaining to theme only.

    @all, if you have experience with the theme Greg is using, please help!

    Posted 1 year ago #
  30. Brajesh,
    I got this back from dev premium...

    "Off the top of my head perhaps because we reference in files in functions.php there could be issues but any well written plugin shouldn't have an issue with that so I don't know. I'm sorry to say but you will have to work out why this is occuring I can only advise roughly as to properly diagnose will require time and deeper analysis when the theme is working it's just this plugin that makes it not work and this isn't even one of our plugins - I hope you understand this situation. I can hint though that you may want to start looking at the other search box.. there are 2 on the theme buddypress daily....... "

    For kicks, I'm going to rebuild it with the default search and include step 1.

    Frustrating. Thanks for all your help!

    Posted 1 year ago #

Reply »

You must log in to post.