Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Generating site search / unnecessary html

Our old forums are still available as a read-only archive.

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

Page: 1 2
Go to End
Author Topic: 3233 Views
  • superautomatic
    Avatar
    Community Member
    53 Posts

    Generating site search / unnecessary html Link to this post

    Hi,

    I'm building a site and added the search-functionality from the tutorial. It seems to me that a lot of unnecessary html is added that I would like to remove but don't know how. For example, new TextField("Search", "", $searchText);

    generates an extra div: <div id="Search" class="field text nolabel">
    and an extra span: <span class="middleColumn">

    How do I get rid of those?

    Best regards,
    Jens

  • Aaron
    Avatar
    Community Member
    63 Posts

    Re: Generating site search / unnecessary html Link to this post

    Boy this is a bit of old thread, but exactly the question I was searching for.

    I don't really care about the unnecessary HTML at the moment, but is there a way to create a form element like the search box and assign a custom css class to it?

    Cheers
    Aaron

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Generating site search / unnecessary html Link to this post

    In your code where you're generating the actual search field, you could do something like this:

    $searchField = new TextField('Search');
    $searchField->addExtraClass('myClass');

    $fields = new FieldSet(
    $searchField
    );

    See here, for the search tutorial: http://doc.silverstripe.com/doku.php?id=tutorial:4-site-search

    Sean

  • bod
    Avatar
    Community Member
    72 Posts

    Re: Generating site search / unnecessary html Link to this post

    Hi - I would really like it if someone could let me know the answer to the original posters question? I'm coming across a lot of unanswered questions in the forum :o/...

    "generates an extra div: <div id="Search" class="field text nolabel">
    and an extra span: <span class="middleColumn"> "

    how does one go about getting rid of this html - can't find it in any .ss files - please help!

  • bod
    Avatar
    Community Member
    72 Posts

    Re: Generating site search / unnecessary html Link to this post

    Well just to update anyone else with this problem searching the board. The only way I could get it to work in the absence of a reply to my post, was to edit the formfield.php file, line 265 to get rid of the div and span tags, (perhaps they shouldn't really be mixed in there as they are for presentation rather than functional elements within form controls, no?).

    The comments in the formfield.php did point to using another file DefaultFieldHolder.ss that should be used to implement a custom look, however this isn't elaborated on as to how this is achieved unfortunately. I did try by placing it in my themes folder and doing the flush=1 trick but it didn't appear to get picked up by SS when placed in there so I'm none the wiser as to it's proper usage or context.... :o(

    Can anyone from the team help to expand on how this file (DefaultFieldHolder.ss) works to create a custom look to forms in the app please?

  • bod
    Avatar
    Community Member
    72 Posts

    Re: Generating site search / unnecessary html Link to this post

    Actually - scrap that, hacking that file just screws the CMS forms up completely. So that still leaves me with a search form that I need to desperately customise.

    Can anyone help with this? Really would appreciate it. Either by using the DefaultFieldHolder.ss or another method please?

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: Generating site search / unnecessary html Link to this post

    I ended up just adding the search form, copying the source code that it generates, the replacing it with hard coded HTML and removing everything I didn't want.

    Worked for me, and obviously there is no answer to this.

  • camspiers
    Avatar
    Community Member
    5 Posts

    Re: Generating site search / unnecessary html Link to this post

    I know this thread is kind of old but from memory you can extend all the existing classes (ie form fields) and set the template that it renders with. You should do all of this in you own code and templates sections of your site. No need at all to modify the core. Also you can extend to Search Engine overwriting the methods you need to change to make the default search better.

    Dio to allow searching in places that are in the sitetree you can add Fulltext to them and then change the Search Engine.

    3233 Views
Page: 1 2
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.