Hi Jac,
You can read how to use CMS Builders search funtionality here:
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html
If you need to search one section only, you can reduce your current code a fair bit, but you will have to modify your search box slightly.
Search box html:
<form method="POST" action="nameOfSearchResultsFile.php">
<input type="text" name="title_keyword" value="">
<input type="submit" name="submit" value="Search">
</form>
So any text entered into the input "title_keyword" will look be searched for in the title field.
Your results page code will need to look something like this:
==================================================
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('C:/wamp/www/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'perPage' => '10',
'loadUploads' => true,
'allowSearch' => true,
));
?><!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; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>
<!-- INSTRUCTIONS -->
<div class="instructions">
<b>Sample List Viewer - Instructions:</b>
<ol>
<?php /*><li style="color: red; font-weight: bold">Rename this file to have a .php extension!</li><x */ ?>
<li><b>Remove any fields you don't want displayed.</b></li>
<li>Rearrange remaining fields to suit your needs.</li>
<li>Copy and paste code into previously designed page (or add design to this page).</li>
</ol>
</div>
<!-- /INSTRUCTIONS -->
<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Blog - List Page Viewer</h1>
<?php foreach ($productsRecords as $record): ?>
Record Number: <?php echo htmlencode($record['num']) ?><br/>
Title: <?php echo htmlencode($record['title']) ?><br/>
Date: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?><br/><!-- For date formatting codes see: http://www.php.net/date -->
Content: <?php echo $record['content']; ?><br/>
jhgjhg (value): <?php echo $record['jhgjhgjhgjhg'] ?><br/>
jhgjhg (label): <?php echo $record['jhgjhgjhgjhg:label'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>
<!-- STEP 2a: Display Uploads for field 'uploads' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
Uploads:
<blockquote>
<?php foreach ($record['uploads'] as $index => $upload): ?>
Upload Url: <?php echo $upload['urlPath'] ?><br/>
<!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.
Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>
Image Tags:<br/>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
info1 (Title) : <?php echo htmlencode($upload['info1']) ?><br/>
info2 (Caption) : <?php echo htmlencode($upload['info2']) ?><br/><br/>
Extension: <?php echo $upload['extension'] ?><br/>
isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
<hr/>
// end uploads comment tag -->
<?php endforeach ?>
</blockquote>
<!-- STEP2a: /Display Uploads -->
<hr/>
<?php endforeach ?>
<?php if (!$productsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->
<!-- STEP3: Display Page Links (Paste anywhere below "Load Record List") -->
<?php if ($productsMetaData['prevPage']): ?>
<a href="<?php echo $productsMetaData['prevPageLink'] ?>"><< prev</a>
<?php else: ?>
<< prev
<?php endif ?>
- page <?php echo $productsMetaData['page'] ?> of <?php echo $productsMetaData['totalPages'] ?> -
<?php if ($productsMetaData['nextPage']): ?>
<a href="<?php echo $productsMetaData['nextPageLink'] ?>">next >></a>
<?php else: ?>
next >>
<?php endif ?>
<!-- /STEP3: Display Page Links -->
</body>
</html>
=======================================
I generated this code using the CMS Builder code generator. I had the "Filter results based on search form input (disable for multiple viewers on one page)" box checked.
Then you need to modify section two of the above to include the fields that you wish to display.
Thanks
Greg
Greg Thomas
PHP Programmer - interactivetools.com