Multi Search - merge two fields into one field for search results

4 posts by 2 authors in: Forums > CMS Builder
Last Post: January 14, 2013   (RSS)

By Mikey - January 14, 2013 - edited: January 14, 2013

Below is my exist code I'm working with:

$searchTables['gallery'] = array(
        'viewerUrl'       => 'gallery_showcase.php',
        'titleField'      => 'title',
        'summaryField'    => 'content',
        'field1'    => 'summary',
        'field2'    => 'prefix_number',
        'field3'    => 'num',
       'searchFields'    =>  array('title','content','summary','prefix_number','num'),
      );

What I need to accomplish:

I need to merge prefix_number and num into a new field prefix_number_num, so as to combine these two fields into one field, so when a user searchers for the prefix and num combined the Multi Search returns the results of the two fields combined.

$searchTables['gallery'] = array(
        'viewerUrl'       => 'gallery_showcase.php',
        'titleField'      => 'title',
        'summaryField'    => 'content',
        'field1'    => 'summary',
        'field2'    => 'prefix_number_num',
       'searchFields'    =>  array('title','content','summary','prefix_number_num'),
      );

Anyone have any suggestions on how to accomplish this task?

Zick

By gregThomas - January 14, 2013

Hi Zick,

The best way to do this would be to create a plugin that combines the two fields after you save or edit an entry in that section. This would be fairly easy to do using the plugin record_postsave hook, and then checking the $_REQUEST array to see if the record is being saved to the gallery section, and then saving/overwriting the prefix_number_num using the mysql_update function. 

We can create this plugin for you if required, if you send an e-mail to consulting@interactivetools.com, and we can give you an estimate on the cost of producing it.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Mikey - January 14, 2013

Thanks for the Plugin guys - works perfectly!