Search join title and subtitle in the titleField of my site search engine

3 posts by 2 authors in: Forums > CMS Builder
Last Post: February 10, 2022   (RSS)

By Mikey - February 4, 2022 - edited: February 4, 2022

I have a news section that has a title and subtitle for the new articles. I need to return search results for both the title and subtitle combined together.

I am trying to change 'titleField' => 'title',  into 'titleField' => 'title.' '.subtitle, but what I have here doesn't work. It's been a long day and I'm too exhausted to think on this. Any suggestions on what I have wrong here?

$searchTables['news'] = array(
 'viewerUrl'       => 'news-article.php',
 //'titleField'      => 'title',
 'titleField'      => 'title.' '.subtitle,
 'summaryField'    => 'content',
 'searchFields'    =>  array('title','summary','content','keywords','categories'),
 'field1'       => 'createdDate',
);

Thanks, Zicky

By daniel - February 10, 2022

Hi Zicky,

With the multi-search, "titleField" can only be a single field. If you'd like to include the subtitle in the results, you could add it as one of the additional returned fields like this:

$searchTables['news'] = array(
 'viewerUrl'       => 'news-article.php',
 'titleField'      => 'title',
 'summaryField'    => 'content',
 'searchFields'    =>  array('title','summary','content','keywords','categories'),
 'field1'       => 'createdDate',
 'field2'       => 'subtitle',
);

Then in the results, the "field2" key should include the subtitle and can be output alongside "_title". 

Let me know if that helps or if you have any other questions!

Thanks,

Daniel
Technical Lead
interactivetools.com