Jump to:

3397 Posts in 978 Topics by 854 members

Template Questions

SilverStripe Forums » Template Questions » Search result page: use MetaDescription as description (just like Google Search)

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

Page: 1 2
Go to End
Author Topic: 3098 Views
  • ck_bullet
    Avatar
    Community Member
    16 Posts

    Re: Search result page: use MetaDescription as description (just like Google Search) Link to this post

    So I'm using a similar query to what CodeGuerilla posted:

    $results = DataObject::get('Product',
    "Title LIKE '%".$this->searchEntry."%' ".
    "OR Brand LIKE '%".$this->searchEntry."%' ".
    "OR PartNumber LIKE '%".$this->searchEntry."%' ".
    "OR MetaTitle LIKE '%".$this->searchEntry."%' ".
    "OR MetaDescription LIKE '%".$this->searchEntry."%' ".
    "OR FIND_IN_SET('".trim($this->searchEntry)."', `MetaKeywords`) > 0", "Title ASC", NULL, "{$SQL_start},".Page::$resultsPerPage);

    with an additional AND clause like: AND (ClassName = 'Lorem' OR ClassName = 'Ipsum')

    Everything works great, but I would like to enhance the query:

    So let's say class 'Lorem' has a child class 'LoremChild'. I would like to modify the query so that it returns 'Lorem' items where any of it's children also have Title LIKE OR Brand LIKE, etc. I don't want the actual child item to be returned in the query, only the parent 'Lorem' item. Any help on this query is greatly appreciated!

  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Re: Search result page: use MetaDescription as description (just like Google Search) Link to this post

    Hi banal, I know this is an old post, but hoping you could help with your CustomSearch function.

    It seems to me that you are specifically excluding Files by not including them in the classes array:

    protected $classesToSearch = array("SiteTree");

    Is that the case? I've been trying to exclude files from the site search, but with no luck...this still returns files. Any ideas?

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