MultiSearch

50 posts by 11 authors in: Forums > CMS Builder
Last Post: August 14, 2012   (RSS)

By Mikey - October 15, 2010

Is there a way to make this multi-search case insensitive?

Dave,
In the code below, you'll see the last $searchTables is for searching information related to photos. I'd like to make my photo's upload "info1 & info2" fields searchable, so people can search for photos based on the photo's title and caption. I've tried to get this work, but I'm doing something wrong. Can you shed a little light on what needs to be done to this code to get the "info1 & info2" data I'm using in my photo title and captions to appear in the search form results.

Thanks, Zick

==========
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

require_once "/this/hosting/cmsbuilder/lib/viewer_functions.php";

// begin search code
list($search_this_siteRecords, $search_this_siteMetaData) = getRecords(array(
'tableName' => 'search_this_site',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$search_this_siteRecord = @$search_this_siteRecords[0]; // get first record

// show error message if no matching record is found
// if (!$search_this_siteRecord) {
// header("HTTP/1.0 404 Not Found");
// print "Record not found!";
// exit;
//}

?>
<?php
// search viewer code begins
$searchOptions = array();
$searchOptions['keywords'] = @$FORM['q'];
$searchOptions['perPage'] = "4";
$searchOptions['debugSql'] = "0";

$searchTables = array();

$searchTables['house'] = array(
'viewerUrl' => 'house_details.php',
'titleField' => 'title',
'summaryField' => 'content',
'searchFields' => array('title','content'),
);

$searchTables['building'] = array(
'viewerUrl' => 'building_details.php',
'titleField' => 'title',
'summaryField' => 'content',
'searchFields' => array('title','content'),
);

$searchTables['photos'] = array(
'viewerUrl' => 'photos_details.php',
'titleField' => 'title',
'summaryField' => 'content',
'uploadField' => 'info1',
'uploadField' => 'info2',
'searchFields' => array('title','content','info1','info2'),
);

list($searchRows, $searchDetails) = searchMultipleTables($searchTables, $searchOptions);
// search viewer code ends
?>
==========

By Jason - October 15, 2010

Hi Zickey,

The image information for a picture is actually stored in the uploads table, not in the section with the upload field. You could try something similar to this:

list($imageRecords,$imageMetaData)=getRecords(array(
'tableName' => 'uploads',
'allowSearch' => false,
'where' => "tableName = 'photos' AND (LOWER(info1) LIKE '%".mysql_escape(strtolower(@$FORM['q']))."%' OR LOWER(info1) LIKE '%".mysql_escape(strtolower(@$FORM['q']))."%')",
));


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [richo] MultiSearch

By gkornbluth - October 12, 2011

Hi Richo,

The php.ini changes you're looking for are not on the CMS Builder level. They're on the web host level.

The default upload size is usually limited to 2mb by the host to prevent misuse of their resources

Ask your webhost to increase the the post_max_size and the upload_max_filesize to something like 60mb and that should cover you for videos and other large files as well.

Most really good hosts will accommodate.


Hope that helps sort things out.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [Jason] MultiSearch

By Mikey - November 10, 2011 - edited: November 10, 2011

Hey Jason,
I tired your solution, to search the upload info1 fields, but it's giving me a notice message:

list($imageRecords,$imageMetaData)=getRecords(array(
'tableName' => 'uploads',
'allowSearch' => false,
'where' => "tableName = 'photos' AND (LOWER(info1) LIKE '%".mysql_escape(strtolower(@$FORM['q']))."%' OR LOWER(info1) LIKE '%".mysql_escape(strtolower(@$FORM['q']))."%')",
));


Notice: Undefined index: listPageOrder in /home/content/00/1230000/html/cms/lib/viewer_functions.php on line 70


Any suggestions on how to get this working?

Re: [zick] MultiSearch

By Jason - November 12, 2011

Hi,

You should be able to get around that issue by putting something in the orderBy clause. Try this:

list($imageRecords,$imageMetaData)=getRecords(array(
'tableName' => 'uploads',
'allowSearch' => false,
'where' => "tableName = 'photos' AND (LOWER(info1) LIKE '%".mysql_escape(strtolower(@$FORM['q']))."%' OR LOWER(info1) LIKE '%".mysql_escape(strtolower(@$FORM['q']))."%')",
'orderBy' => "`order`",
'loadUploads' => false,
'loadCreatedBy' => false,
));


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] MultiSearch

By Mikey - July 26, 2012

Is it possible to search a second tier category (excluding the first tier) using MultiSearch, thereby the search results only displays tier two category results and ignores the top tier categories?
$searchTables['news'] = array(
'viewerUrl' => 'news_details.php',
'titleField' => 'title',
'summaryField' => 'content',
'searchFields' => array('title','content'),

$searchTables['business_listings'] = array(
'viewerUrl' => 'business_listing_details.php',
'titleField' => 'name',
'summaryField' => 'content',
'searchFields' => array('name','content'),
'categoryFormat' => twolevel',
);

Re: [zick] MultiSearch

By Jason - July 30, 2012

Hi Zick,

There currently isn't any support for that in multiSearch. However, if you needed to do that, you could filter out non-2nd Level records when outputting results since all 2nd level Records have a value of "1" in their "depth" field.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] MultiSearch

By alissibronte - August 13, 2012 - edited: August 13, 2012

Hi guys,

i'm trying to do a multisearch page but i can't understand how search fields works.

Here is my code:
//SEARCH CODE

$searchOptions = array();
$searchOptions['keywords'] = @$FORM['q'];
$searchOptions['perPage'] = "15";
$searchOptions['debugSql'] = "0";

$searchTables = array();

$searchTables['thome'] = array(
'viewerUrl' => 'index.php',
'titleField' => 'title',
'summaryField' => 'text',
'searchFields' => array('text'),
);

$searchTables['history'] = array(
'viewerUrl' => 'history.php',
'titleField' => 'title',
'summaryField' => 'text',
'searchFields' => array('title','text'),
);

$searchTables['news'] = array(
'viewerUrl' => 'news.php',
'titleField' => 'title',
'summaryField' => 'text',
'searchFields' => array('title','text'),
);

list($searchRows, $searchDetails) = searchMultipleTables($searchTables, $searchOptions);

$searchRow = @$searchRows[0];


<form method="post" action="/search.php">
<input type="text" name="q" value="" />
<input type="submit" name="submit" value="Search" class="submit" />
</form>

<?php foreach ($searchRows as $record): ?>
<p><a href="<?php echo $record['_link']; ?>" title="<?php echo htmlspecialchars($record['title']); ?>"><?php echo htmlspecialchars($record['title']); ?></a></p>
<?php endforeach; ?>



My questions:

Is possible to set form search field with multiple keywords?
e.x: <input type="text" name="preview_text,text,type,line,meta_description" value="" />
$searchOptions['keywords'] = @$FORM['preview_text,text,type,line,meta_description'];

I dont understand how works these params:
'titleField' => 'title',
'summaryField' => 'text',

I'm getting error Undefined index: title. Please help me a little.

Thank you, regards!

Re: [Jason] MultiSearch

By alissibronte - August 14, 2012 - edited: August 14, 2012

Once again you've helped me a lot.

Now I have to get the last step, extract images from the news that match the search.


Great! Thank you Jason.