Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Problems with the search function.

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

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

Page: 1
Go to End
Author Topic: 1446 Views
  • SLJ
    Avatar
    Community Member
    23 Posts

    Problems with the search function. Link to this post

    This may actually belong in the bugs section. I built the search function following the instructions in "4-site-search." and it works flawlessly most of the time but I discovered that if an entry that qualifies as a search result has an ampersand in it, it fails with the following:

    XML Parsing Error: not well-formed
    Location: http://localhost/silverstripe/media-appearances/results?Search=Heart&formController=media-appearances%2F&executeForm=SearchForm&action_results=Go
    Line Number 88, Column 19:

    “The Heart & Soul
    ------------------^

    You can't see it here, but in the actual error the caret is pointing to the space after the ampersand. How can I fix this?

  • Andy
    Avatar
    230 Posts

    Re: Problems with the search function. Link to this post

    You can fix this by changing $Content.LimitWordCountPlainText to $Content.LimitWordCountXML in the template. I've updated the tutorial with this.

  • SLJ
    Avatar
    Community Member
    23 Posts

    Re: Problems with the search function. Link to this post

    Thanks. That took care of the error message. Now I have a different issue. The content has special characters in it and the html for those characters is now showing up on the search results page. Like this:

    Media appearances in the following documentaries
    “The Heart & Soul Series” by ABC-TV

    The text shows up the way it's supposed to on the actual page it's from. Any ideas how to fix this?

  • Andy
    Avatar
    230 Posts

    Re: Problems with the search function. Link to this post

    This appears to be a problem with tinymce's cleanup of HTML content. I will make a ticket in our bug system for this, for now try changing your angled quotes to standard ones - " .

  • SLJ
    Avatar
    Community Member
    23 Posts

    Re: Problems with the search function. Link to this post

    Andy,

    Thanks for looking into this. I tried what you said at it still does it even with standard quotation marks.

    Is there some way I can parse the search results to get rid of the HTML code before it's displayed on the page?

    It's putting in "amp;" after the ampersands so that the resulting HTML has "&" which makes them display as ampersands instead of being used in the HTML like they're supposed to be. If I could somehow strip out the "amp;" strings. it would display normally.

    What's the best way to do that?

  • Andy
    Avatar
    230 Posts

    Re: Problems with the search function. Link to this post

    Try using $Content.FirstParagraph instead.

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