Jump to:

23372 Posts in 18175 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » Search box - remove "search" above box

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1669 Views
  • Valorinbattle
    Avatar
    Community Member
    95 Posts

    Search box - remove "search" above box Link to this post

    I used the WebPI silverstripe locally and all worked great, but when I used the other install to get my site up on my host, the search box adds the word "search" above the input field. I'm not referring to the word "search" in the input field, but just above it. How do I remove this? I did a search thru the code of the entire site and couldn't find it. Please see attached picture.

    Attached Files
  • dalesaurus
    Avatar
    Community Member
    283 Posts

    Re: Search box - remove "search" above box Link to this post

    That is the label on the form. Easiest way to get rid of it would be with CSS, target by ID and set display: hidden;

  • Jace
    Avatar
    Community Member
    1 Post

    Re: Search box - remove "search" above box Link to this post

    Unfortunately the CSS addition doesn't work, as I've tried it myself. Try this though... open up your Page.php file, and remove this string of code:

    $searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'Search';

    That should give you an empty search box on your site, and not affect the search function. You could also replace the word 'Search' at the end of the string above with whatever you'd like it to say as well; Enter keyword, Search here etc...

    Hope this helped,

    Jace

  • Valorinbattle
    Avatar
    Community Member
    95 Posts

    Re: Search box - remove "search" above box Link to this post

    Thanks Jace. Actually when I downloaded the newest Silverstripe version and installed it, "Search" was no longer listed above the search box, so they must have fixed it between versions.

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: Search box - remove "search" above box Link to this post

    /**
        * Site search form
        */
       function SearchForm() {
          $searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'sometext or nothing';
          $fields = new FieldSet(
           new TextField("Search", "", $searchText)
           );
          $actions = new FieldSet(
           new FormAction('results', 'Search')
           );

           return new SearchForm($this, "SearchForm", $fields, $actions);
       }
       
       /**
        * Process and render search results
        */

    change to

    /**
        * Site search form
        */
       function SearchForm() {
          $searchText = isset($_REQUEST['sometext or nothing']) ? $_REQUEST['sometext or nothing'] : 'Search';
          $fields = new FieldSet(
           new TextField("Search", "", $searchText)
           );
          $actions = new FieldSet(
           new FormAction('results', 'Search')
           );

           return new SearchForm($this, "SearchForm", $fields, $actions);
       }
       
       /**
        * Process and render search results
        */

    1669 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.