MultiSearch
4 posts by 2 authors in: Forums > CMS Builder
Last Post: Wednesday at 1:14pm (RSS)
By MercerDesign - June 25
Hi, I've used the multiSearch.php before but I can't get it to work on this new site, is there a most recent example? Here is the code I have in place based on the example I found on this forum.
<!-- STEP1: Load Record List (Paste this above other steps) -->
<?php
require_once "cmsb/lib/viewer_functions.php";
$searchOptions = array();
$searchOptions['keywords'] = @$_REQUEST['q'];
$searchOptions['perPage'] = "10";
$searchOptions['debugSql'] = "1";
$searchTables = array();
$searchTables['wilsons_school_navigation'] = array(
'viewerUrl' => 'welcome-to-wilsons',
'titleField' => 'title',
'contentField' => 'content',
'searchFields' => array('title','content'),
);
list($searchRows, $searchDetails) = searchMultipleTables($searchTables, $searchOptions);
?>
<!-- /STEP1: Load Record List -->
<form method="GET" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" >
<input class="text-input medium-input" type="text" name="q" value="<?php echo htmlencode(@$_REQUEST['q']); ?>" size="50">
<input class="button" type="submit" name="null" value="Search"><br/><br/>
<table border=0 cellpadding=2 cellspacing=0 width=100%>
<tr>
<td bgcolor="#EEEEEE"><font size=2 class="maintext">Search results for <b><?php echo htmlencode(@$_REQUEST['q']); ?></b></font></td>
<td bgcolor="#EEEEEE" align="right"><font size=2 class="maintext">Results
<b><?php echo htmlencode(@$searchDetails['pageResultsStart']); ?></b> to
<b><?php echo htmlencode(@$searchDetails['pageResultsEnd']); ?></b> of
<b><?php echo htmlencode(@$searchDetails['totalRecords']); ?></b>.</font></td>
</tr>
</table><br/>
<!-- show errors -->
<?php if ($searchDetails['invalidPageNum']): ?>
Results page '<?php echo $searchDetails['page']?>' not found, <a href="<?php echo $searchDetails['firstPageLink'] ?>">start over >></a>.<br/>
<?php elseif ($searchOptions['keywords'] && $searchDetails['noRecordsFound']): ?>
No records matched search query!<br/><br/>
<?php elseif ($searchOptions['keywords'] == ""): ?>
Enter a keyword to search.<br/><br/>
<?php endif ?>
<!-- STEP2: Display Record List -->
<?php foreach ($searchRows as $record): ?>
<?php //showme($record); ?>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['_title'] ?></a><br/>
<?php if ($record['_summary']): ?>
<?php echo $record['_summary'] ?><br/>
<?php else: ?>
No description available for page.<br/>
<?php endif ?>
<a href="<?php echo $record['_link'] ?>" style="color: #008000"><?php echo $record['_link'] ?></a><br/><br/>
<?php endforeach ?>
<!-- /STEP2: Display Record List -->
<!-- STEP3: Display Page Links (Paste anywhere below "Load Record List") -->
<?php if ($searchDetails['prevPage']): ?>
<a href="<?php echo $searchDetails['prevPageLink'] ?>"><< prev</a>
<?php else: ?>
<< prev
<?php endif ?>
- page <?php echo $searchDetails['page'] ?> of <?php echo $searchDetails['totalPages'] ?> -
<?php if ($searchDetails['nextPage']): ?>
<a href="<?php echo $searchDetails['nextPageLink'] ?>">next >></a>
<?php else: ?>
next >>
<?php endif ?>
<!-- /STEP3: Display Page Links -->
</form>
Hi, MercerDesign.
I've not seen a version with " 'contentField' => 'content' '".
To use fields in addition to titleField and summaryField, I've been using 'field1', 'field2', etc., like this:
$searchTables['stores'] = array(
'viewerUrl' => '/stores/about.php',
'titleField' => 'store_name',
'summaryField' => 'description',
'field1' => 'location',
'field2' => 'region',
'field3' => 'reference_names',
'searchFields' => array('store_name','description','location','region','reference_names'),
);
<!-- STEP2: Display Record List -->
<?php if ($searchRows): ?>
<?php foreach ($searchRows as $record): ?>
<?php echo $record['_title'] ?>
<?php echo $record['_summary'] ?>
<?php echo $record['field1'] ?>
<?php echo $record['field2'] ?>
<?php echo $record['field3'] ?>
<?php endforeach ?>
Note there is no underscore included in the added fields.
Also, I see your 'viewerUrl' is not a valid path.
Hope that helps!
~ Deborah
By MercerDesign - June 25
Thank you, I've use the content field before and it used to work so I don't think that is the issue.
Sorry I couldn't help. Maybe if you post a few more details about what is/isn't happening, someone with more MultiSearch knowledge could help.
~ Deborah