Jump to:

3444 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » Changing or Removing "Search" Text on Search Button (BlackCandy), so background image shows clearly

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

Page: 1
Go to End
Author Topic: 2420 Views
  • AlastairW
    Avatar
    Community Member
    5 Posts

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

    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
  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: Changing or Removing "Search" Text on Search Button (BlackCandy), so background image shows clearly Link to this post

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

  • AlastairW
    Avatar
    Community Member
    5 Posts

    Re: Changing or Removing "Search" Text on Search Button (BlackCandy), so background image shows clearly Link to this post

    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

  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: Changing or Removing "Search" Text on Search Button (BlackCandy), so background image shows clearly Link to this post

    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.

  • AlastairW
    Avatar
    Community Member
    5 Posts

    Re: Changing or Removing "Search" Text on Search Button (BlackCandy), so background image shows clearly Link to this post

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

    2420 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.