Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

How to change ”Search anything…” (12 posts)

Started 1 year, 2 months ago by: aljuk

  • Profile picture of aljuk aljuk said 1 year, 2 months ago:

    I’d like to make “Search anything…” more accurate.

    ie. “Search Members…”, “Search Groups…”, “Search Group Forums…”

    Is there an easy way to do this without hacking core?

  • Profile picture of Virtuali Virtuali said 1 year, 2 months ago:

    This is what you want to change:

    if ( !empty( $_POST['search_terms'] ) && __( 'Search anything...', 'buddypress' ) in your theme’s ajax.php

  • Profile picture of aljuk aljuk said 1 year, 2 months ago:

    @gunju2221 Thanks, I saw that, but as far as I can tell, that’s for the hint text if searching using ajax (?)

    What I’ve done is replaced the appropriate strings in :

    bp-blogs/bp-blogs-templatetags.php
    bp-core/bp-core-templatetags.php
    bp-forums/bp-forums-templatetags.php
    bp-groups/bp-groups-templatetags.php

    which appears to have done the trick. Searches are working fine, as is the hint text.

    Let me know if you foresee any problem with this!

  • Profile picture of r-a-y r-a-y said 1 year, 2 months ago:

    Use a language file:

    http://codex.buddypress.org/extending-buddypress/customizing-labels-messages-and-urls/

  • Profile picture of aljuk aljuk said 1 year, 2 months ago:

    Awesome, thanks @r-a-y .

  • Profile picture of aljuk aljuk said 1 year, 2 months ago:

    For anyone reading this thread, definitely do as suggested above, not as I did, which led to some unforseen complications.

  • Profile picture of cezar cezar said 12 months ago:

    the language file has only one instance of “Search anything” so you can’t have a different message in the search boxes. how did you do it?

  • Profile picture of valuser valuser said 11 months, 2 weeks ago:

    Could @aljuk elaborate on the unforseen complications that arose from replacing the appropriate strings in bp-blogs/bp-blogs-templatetags.php etc. ?

  • Profile picture of aljuk aljuk said 11 months, 2 weeks ago:

    @cezar – I didn’t, for the precise reason you mentioned.

    @valuser – it broke the search on those directories.

    Changing it for certain other plugins that make use of search (Buddyvents, Global Forums) has been successful, and I did that by straightforward hacking those plugins.

  • Profile picture of d3creative d3creative said 9 months, 3 weeks ago:

    @cezar “the language file has only one instance of “Search anything” so you can’t have a different message in the search boxes. how did you do it?”

    Anyone found a workaround for this?

  • Profile picture of Alan Alan said 9 months, 3 weeks ago:

    ok I’ve made something really fast for you….

    0.1 place this function into your functions file at the end of the closing php tag ” ?> ” !

    <?php
    function uloga_directory_search_form( $directory ) {
    	global $bp;
            $form_id   = 'search-' . $directory . '-form';
            $input_id  = $directory . '_sarch';
            $submit_id = $directory . '_search_submit';
    
    	$search_value = __( 'Search ' . $directory, 'buddypress' );
    	if ( !empty( $_REQUEST['s'] ) )
    	 	$search_value = $_REQUEST['s'];
    
    ?>
    	<form action="" method="get" id="<?php $form ;?>">
    		<label><input type="text" name="s" id="<?php $input_id ;?>" value="<?php echo esc_attr($search_value) ?>"  onfocus="if (this.value == '<?php _e( 'Search ' . $directory, 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search ' . $directory, 'buddypress' ) ?>';}" /></label>
    		<input type="submit" id="<?php $submit_id ;?>" name="groups_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    	</form>
    <?php
    }
    ?>

    0.2 now you have to change the bp_directory_members_search_form() function with uloga_directory_search_form( $directory ) ,replace $directory for example with “Members”
    or “Groups” ,etc.

  • Profile picture of Alan Alan said 9 months, 3 weeks ago:

    p.s i mean you have to replace bp_directory_members_search_form() with the new function in your theme directory files.