Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Changing or Removing "Search" Text on Search Button (BlackCandy), so background image shows clearly


Go to End


5 Posts   5046 Views

Avatar
AlastairW

Community Member, 5 Posts

1 April 2010 at 9:27pm

Edited: 01/04/2010 9:27pm

Hi,

I'm struggling to figure out how to remove the word "Search" from the search button provided in the BlackCandy theme (see attached image). I've applied a background image which shows a nice graphic, so I don't want text over it. If I can make the <input ... value=""> then it works fine, but I can't track down where to do this. I can't even seem to change the text, let alone remove it. I've tried changing all the words 'Search' and 'Go' in SearchForm.php:

	function __construct($controller, $name, $fields = null, $actions = null, $showInSearchTurnOn = true) {
		$this->showInSearchTurnOn = $showInSearchTurnOn;
		
		if(!$fields) {
			$fields = new FieldSet(
				new TextField('Search', _t('SearchForm.SEARCH', 'Search')
			));
		}
		
		if(singleton('SiteTree')->hasExtension('Translatable')) {
			$fields->push(new HiddenField('locale', 'locale', Translatable::get_current_locale()));
		}
		
		if(!$actions) {
			$actions = new FieldSet(
				new FormAction("getResults", _t('SearchForm.GO', 'Go'))
			);
		}

...but nothing seems to make a difference.

I've been doing dev/build?flush=1 and ?flush=1 while trying every combination. The SS tutorial on making the site search function shows the word "Go", which doesn't happen on my install, so I assume that's out of date? And there's a similar question solved here that's from January, but again the code doesn't seem to match mine? I'm just baffled what to try next.

In FF & Chrome I've solved it just by setting the text color to transparent but that doesn't work in IE.

Any ideas where to from here?

(I'm developing on SS2.3.3 localhost version, but the live website is running 2.3.7, if that makes a difference. The MS Web Installer Platform is still distributing 2.3.3 which is what I used to get up and running, being an amateur at this stuff.)

Cheers,
Alastair

Attached Files
Avatar
baba-papa

Community Member, 279 Posts

2 April 2010 at 8:39pm

Try to replace "_t('SearchForm.GO', 'Go')" by "".

Avatar
AlastairW

Community Member, 5 Posts

2 April 2010 at 9:43pm

Thanks for the tip baba, but it didn't seem to have any effect at all. Nothing I've changed in SearchForm.php has made any difference that I can notice, it's like I'm editing the wrong file or something. I'm editing websitedir/sapphire/search/SearchForm.php, and then doing a dev/build?flush=1 and ?flush=1, but nothing at all seems to change.

From your tip I tried changing

new FormAction("getResults", _t('SearchForm.GO', 'Go'))

to
new FormAction("getResults", _t('SearchForm.GO', ''))

and then
new FormAction("getResults")

Wrong file? Or is it being cached somewhere and not flushed?

Thanks

Avatar
baba-papa

Community Member, 279 Posts

2 April 2010 at 9:48pm

Of course you are in the wrong file, sorry I din´t notice. The search form is defined in a controller, I guess Page_Controller. The method might look like this:

	function SearchForm() {
		$searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'Search';
		$fields = new FieldSet(
	      	new TextField("Search", "", $searchText)
	  	);
		$actions = new FieldSet(
	      	new FormAction('results', 'Search')
	  	);

	  	return new SearchForm($this, "SearchForm", $fields, $actions);
	}

Change FormAction('results', 'Search') to FormAction('results', '').
Never mess with the framework or core files.

Avatar
AlastairW

Community Member, 5 Posts

2 April 2010 at 9:54pm

Ahh brilliant! Thanks so much. Damn I really should've figured to look in there though, looked everywhere else!