Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Search custom fields

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

Page: 1
Go to End
Author Topic: 2058 Views
  • inCharge
    Avatar
    Community Member
    102 Posts

    Search custom fields Link to this post

    What I like most about SilverStripe is that it's easy to create templates with more than one content field, and for the site owner to edit that content.

    If your page has custom fields on it the search currently cannot handle searching these. It will only search the default title, content fields
    http://www.silverstripe.org/archive/show/196669#post196669

    How can the site search find the content of custom fields? This is surely something most SilverStripe developers need to implement at some point?

    things like the forum have got there own custom search forms with their own querying engines.
    http://www.silverstripe.org/form-questions/show/256689

    I looked at the forum search, then had to lie down. It'll take days to unravel that lot. I'd be most grateful if someone could post an example, or link to a recipe.

    Thanks,
    Jules

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Search custom fields Link to this post

    If you can set up sphinx search. It's designed to be extended much more and has a bunch of nice features (like searching custom fields and file content)

    http://silverstripe.org/sphinx-module

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Search custom fields Link to this post

    I used a *hack* on a site recently that amalgamated the contents of my custom fields and stuck them in the MetaDescription field onBeforeWrite, which is searched by the default search.

    I then created a custom db field to hold the actual meta description and replaced the field under the metadata tab with my own, as well a overriding the MetaTags fucntion to use my replacment field in it's return value.

    I know this is a bit of a dirty hack, but if it's quick implentation you are after then it works well with very little overhead.

    Aram

    ---------------------------------------------------------------------------------

    www.ssbits.com - Your one stop SilverStripe learning resource

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Search custom fields Link to this post

    I've got a basic recipe that I've posted in this thread, hope it helps...

    http://www.silverstripe.org/customising-the-cms/show/288544#post288544

  • inCharge
    Avatar
    Community Member
    102 Posts

    Re: Search custom fields Link to this post

    Thanks guys. That gives me 3 options

    1 - Sphinx
    2 - Concatonate searchable fields into MetaDescription
    3 - Custom search

    I'd call 2 a 'quick fix' rather than a 'dirty hack'. It's probably more efficient than 3 because only one field is searched. You'd probably want to use an XML parser to strip the HTML tags out of the searchable content though.

    If I was going to do one SilverStripe site then move on, I'd use 2. If I used shared hosting so couldn't install Sphinx then I'd use 3. But Sphinx has to be the way to go.

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Search custom fields Link to this post

    I have been wanting to get round to sphinx module for some time, please let us know how you get on. I'd like to upgrade all my search so that it includes search pdfs and dynamically created pages... so as I say I'd be very interested in your results...

  • inCharge
    Avatar
    Community Member
    102 Posts

    Re: Search custom fields Link to this post

    > please let us know how you get on
    Sure, will do, when I get around to setting it up

    The other bespoke CMS I work with uses Xapian, which is very fast + flexible + scalable and doesn't require a separate daemon. So it'll be interesting to see how Sphinx compares.

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