MultiSearch

9 posts by 3 authors in: Forums > CMS Builder
Last Post: July 3   (RSS)

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 &gt;&gt;</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'] ?>">&lt;&lt; prev</a>
<?php else: ?>
&lt;&lt; prev
<?php endif ?>

- page <?php echo $searchDetails['page'] ?> of <?php echo $searchDetails['totalPages'] ?> -

<?php if ($searchDetails['nextPage']): ?>
<a href="<?php echo $searchDetails['nextPageLink'] ?>">next &gt;&gt;</a>
<?php else: ?>
next &gt;&gt;
<?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

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

By Deborah - July 2 - edited: July 2

Just a guess... on the search results page HTML, the "unwanted code" showing in-browser is wrapped in an <xmp> tag.

HTML Validator: From line373, column5; to line373, column9
Element xmp not allowed as child of element div in this context

Unless you have purpose for the <xmp>, which I'm reading was deprecated, you might try replacing or removing it.

~ Deborah

Hi MercerDesign,

My proposal may be naive, but did you set debugSql to 0?

I really like your gsap page! You're the one who coded it?

Thanks,
Djulia

Thank you, that worked. Yes I designed and coded the page myself.

I've got the search working but how can I get it to search a category name, I have category menus but it's not searching the name.