Multisearch.php results links

12 posts by 4 authors in: Forums > CMS Builder
Last Post: June 9, 2011   (RSS)

By rishi_143 - June 2, 2011

Hi,
Helping a friend out in adding search to his CMSB website.
I have managed to get the multisearch to display results,
but the links in the results are just looping back to multisearch.php

I used the standard code, only modified the tables n fieldnames.

Any help is greatly appreciated.

ps: CMSB 1.26
the actual webdesigner has disappeared (after charging a bomb) so m trying to figure this out for my friend.

Thanx in advance.

Re: [rishi_143] Multisearch.php results links

By Jason - June 2, 2011

Hi,

Would you be able to attach a copy of the code you're using and provide a link to where we can see the problem in action? If you don't want to post this information in the forum, you can send it in an email to support@interactivetools.com.

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.php results links

By rishi_143 - June 3, 2011 - edited: June 3, 2011

Thanx for your quick reply...
-----------------------------------
Searchbox code on index.php
-----------------------------------
<!-- STEP1: Load Record List (Paste this above other steps) -->
<?php
require_once "WITHELD/lib/viewer_functions.php";
$searchOptions = array();
$searchOptions['keywords'] = @$FORM['q'];
$searchOptions['perPage'] = "10";
$searchOptions['debugSql'] = "0";

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

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

list($searchRows, $searchDetails) = searchMultipleTables($searchTables, $searchOptions);
?>
<!-- /STEP1: Load Record List -->

<form id="form1" method="POST" action="multiSearch.php" >
<label><span>
<input type="text" name="q" class="keywords" id="textfield" maxlength="50" value="<?php echo htmlspecialchars(@$FORM['q']); ?>" size="50">
</span>
<input type="image" src="images/search.gif" class="button" name="b" value="Search">
</label>
</form>


--------------------------
Multisearch.php code
--------------------------


<?php echo "<?xml version='1.0'?>\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; font-size: 12px; }
</style>
</head>
<body>


<!-- STEP1: Load Record List (Paste this above other steps) -->
<?php
require_once "WITHELD/lib/viewer_functions.php";
$searchOptions = array();
$searchOptions['keywords'] = @$FORM['q'];
$searchOptions['perPage'] = "10";
$searchOptions['debugSql'] = "0";

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

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

list($searchRows, $searchDetails) = searchMultipleTables($searchTables, $searchOptions);
?>
<!-- /STEP1: Load Record List -->

<h1>Search Viewer</h1>

<form method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<input type="text" name="q" value="<?php echo htmlspecialchars(@$FORM['q']); ?>" size="50">
<input type="submit" name="" 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 htmlspecialchars(@$FORM['q']); ?></b></font></td>
<td bgcolor="#EEEEEE" align="right"><font size=2 class="maintext">Results
<b><?php echo htmlspecialchars(@$searchDetails['pageResultsStart']); ?></b> to
<b><?php echo htmlspecialchars(@$searchDetails['pageResultsEnd']); ?></b> of
<b><?php echo htmlspecialchars(@$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): ?>
<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>
</body>
</html>

-----------------------------------------------------
As u can see I havent changed much in the original code...

Re: [rishi_143] Multisearch.php results links

By Jason - June 3, 2011

Hi,

It looks like the issue is with the value of "viewerUrl" :

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

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


You can change the value of viewerUrl from "multiSearch.php" to the page that you want to link to for of the sections your searching.

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.php results links

By zip222 - June 3, 2011

This multisearch is really cool. I knew this existed but hadn't given it a try until. fairly easy to implement. Question though...

If I want my title fields to be more descriptive, how would I go about doing that. For example, I want the titles in the results to look this:

Portfolio / Interactive / Project Title

"Project Title" is only thing that I can pull from the CMS. The other text would need to prepended to the titleFields. I would be searching multiple tables at the same time, each requiring a unique set of prepended text.

Re: [rishi_143] Multisearch.php results links

By Jason - June 5, 2011

Hi,

The viewerUrl page is the page where you will view the details of a specific record.

For example, if you use a file called newsDetails.php to view an individual news record, you would probably what to use this as your viewerUrl for the news section.

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.php results links

By rishi_143 - June 6, 2011

Hey Jason,
Works perfect, thanx alot for your patience and prompt replies.
I will surely recommend CMSB to my other friends n clients.

Thanx again,

Rishi

Re: [zip222] Multisearch.php results links

By zip222 - June 7, 2011

I think this question got lost in the shuffle. My own fault for trying to hijack the thread :)

Help?

Re: [zip222] Multisearch.php results links

By Jason - June 8, 2011

Hi,

Sorry for the delay there.

You can modify the title while you're outputting your records:

<!-- STEP2: Display Record List -->
<?php foreach ($searchRows as $record): ?>
<a href="<?php echo $record['_link'] ?>">Add Extra Text Here<?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 -->


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/