Add class to searchbar input

This topic contains 4 replies, has 3 voices, and was last updated by  Giri 6 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #384313

    Falk Meyer-Plate
    Free User
    Post count: 14

    Hello,

    i was wondering how i can hook into the searchbar input function to add my bootstrap form classes to get everything lined up well.

    Greets,
    Falk

    EDIT:
    I ran into an issue when i try to remove the search widget via the customizer, i am not able to open up the dropdown for this section. Settings for map and categories are working fine.

    #384362

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    I alerted the developers about your question. They’ll let you know asap.

    Thanks

    #384510

    Giri
    Expired Member
    Post count: 3155

    Hi Falk, Please provide the html code with your class. I’ll add the code and give you.

    Thanks

    #384594

    Falk Meyer-Plate
    Free User
    Post count: 14

    Hi Giri,

    basicly i just need an extra class of “form-control” added to the input field.

    I kinda worked around my customizer issue by manually setting the display property from none to block.

    Thanks

    #384731

    Giri
    Expired Member
    Post count: 3155

    Hi Falk,

    I still have no idea what are the fields you talking about. I presume its Search input and near input fields.

    If thats the case use this code.

    
    
    remove_action( 'geodir_search_form_inputs', 'geodir_search_form_search_input', 20 );
    add_action( 'geodir_search_form_inputs', 'custom_geodir_search_form_search_input', 20 );
    function custom_geodir_search_form_search_input() {
    
    	$default_search_for_text = SEARCH_FOR_TEXT;
    	if ( get_option( 'geodir_search_field_default_text' ) ) {
    		$default_search_for_text = __( get_option( 'geodir_search_field_default_text' ), 'geodirectory' );
    	}
    
    	$new_style = get_option('geodir_show_search_old_search_from') ? false : true;
    	if($new_style){
    		echo "<div class='gd-search-input-wrapper gd-search-field-search'>";
    	}
    	?>
    	<input class="search_text form-control" name="s"
    	       value="<?php if ( isset( $_REQUEST['s'] ) && trim( $_REQUEST['s'] ) != '' ) {
    		       echo esc_attr( stripslashes_deep( $_REQUEST['s'] ) );
    	       } else {
    		       echo $default_search_for_text;
    	       } ?>" type="text"
    	       onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql( $default_search_for_text ); ?>';}"
    	       onfocus="if (this.value == '<?php echo esc_sql( $default_search_for_text ); ?>') {this.value = '';}"
    	       onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);">
    	<?php
    	if($new_style){
    		echo "</div>";
    	}
    }
    
    add_filter('geodir_search_near_class', 'custom_geodir_search_near_class');
    function custom_geodir_search_near_class() {
    	return "form-control";
    }
Viewing 5 posts - 1 through 5 (of 5 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket