Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to override core template function

  • Avatar of Skeary
    Skeary
    Participant

    @skeary

    I want to change the bp_directory_groups_search_form() function in bp-groups-template.php to change how the search form displays.

    What’s the best way to do this in my theme? I would put something in my theme’s functions.php but not sure best way to do this.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Avatar of Hugo
    Hugo
    Moderator

    @hnla

    It and the others now have filters so you can filter in to the function bp-groups-template.php approx line: 2496.

    Out of interest what did you want to change about the form?

    Avatar of Skeary
    Skeary
    Participant

    @skeary

    Oh sweet.. is the filter tag same as the function name?

    I need to make the button say ‘Go’ instead of ‘Search’ to match a comp.

    Avatar of aces
    aces
    Participant

    @aces

    Avatar of meg@info
    meg@info
    Participant

    @megainfo

    Hi @Skeary,

    There is no filter for bp_directory_groups_search_form(), You can change create a new custom function and replace the old call of bp_directory_groups_search_form by the new function.

    
    function bp_custom_directory_groups_search_form() {
    
    	$default_search_value = bp_get_search_default_text( 'groups' );
    	$search_value         = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; ?>
    
    	<form action="" method="get" id="search-groups-form">
    		<label><input type="text" name="s" id="groups_search" placeholder="<?php echo esc_attr( $search_value ) ?>" /></label>
    		<input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e( 'Go', 'buddypress' ) ?>" />
    	</form>
    
    <?php
    }
    

    The other solution is by javascript, you can change the text of the button by this code :

    
    jQuery('#groups_search_submit).attr('value','Go');
    
    
    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    @megainfo Actually you’re quite correct… well almost, there are filters and they were committed but think the commit was rolled back as I found a few issues and the updates didn’t make it into 1.8.1 but check your trunk files you’ll see them there.

    @skeary Apologies I was ahead of myself there, next release will contain them; for the moment follow Aces advice or megainfos new function to replace.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.