WordPress.org

Ready to get started?Download WordPress

Forums

Enhanced Search Box
[resolved] The placeholder appear only on focus (4 posts)

  1. natostanco
    Member
    Posted 1 year ago #

    The default placeholder is shown until I click on the searchbar, than the customized placeholder is show, headway theme.

    http://wordpress.org/extend/plugins/extended-search-plugin/

  2. jcow
    Member
    Plugin Author

    Posted 1 year ago #

    I couldn't say for sure what is going on without seeing the code for theme.

    I imagine that the theme is already doing it's own stuff to manage the searchbox and this plugin might be incompatible.

  3. natostanco
    Member
    Posted 1 year ago #

    the theme function for the place holder is this:

    function headway_get_search_form($placeholder = null) {
    
    	if ( !$placeholder )
    		$placeholder = __('Type to search, then press enter', 'headway');
    
    	$placeholder = apply_filters('headway_search_form_placeholder', $placeholder);
    	$search_query = get_search_query();
    	$search_input_attributes = array(
    		'type' => 'text',
    		'class' => 'field',
    		'name' => 's',
    		'id' => 's'
    	);
    
    	/* Handle the placeholder and value */
    		//$search_input_attributes['placeholder'] = $placeholder;
    
    		$search_input_attributes['value'] = $search_query ? $search_query : $placeholder;
    
    		$search_input_attributes['onclick'] = 'if(this.value==\'' . $placeholder . '\')this.value=\'\';';
    		$search_input_attributes['onblur'] = 'if(this.value==\'\')this.value=\'' . $placeholder . '\';';
    
    	/* Turn the array into real HTML attributes */
    		$search_input_attributes = apply_filters('headway_search_input_attributes', $search_input_attributes);
    		$search_input_attributes_string = '';
    
    		foreach ( $search_input_attributes as $attribute => $value )
    			$search_input_attributes_string .= $attribute . '="' . $value . '" ';
    
    	return '
    		<form method="get" id="searchform" action="' . esc_url(home_url('/')) . '">
    			<label for="s" class="assistive-text">' . __('Search', 'headway') . '</label>
    			<input ' . trim($search_input_attributes_string) .' />
    			<input type="submit" class="submit" name="submit" id="searchsubmit" value="' . esc_attr__('Search', 'headway') . '" />
    		</form>
    	';
    
    }

    I commented out the first two lines, the conditional to add the default theme placeholder, and enhanced search box works ok. See if you can fix the plugin so that there is no need to edit theme functions?

  4. jcow
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for the update.

    This is a really basic plugin to add better placeholder functionality to the out-of-the-box searchbox. There really isn't a way to compensate for every single theme out there. They are all different and it depends on how the theme developer has decided to modify the searchbox. Some themes just won't be compatible with the plugin.

    I am glad you found a way to get it to work with your theme though.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.