Adding a viewer Search Engine

13 posts by 2 authors in: Forums > CMS Builder
Last Post: April 7, 2011   (RSS)

By csdesign - April 4, 2011

Hello! For whatever reason this is just not clicking with me. I've read a bunch of posts on it but I'm missing something very obvious I'm sure. I'm almost ashamed to even ask. :)

I have this reference page:
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

and I tried to view the multiSearch.php file here, but it's not coming up because it says the page contains errors:
http://www.interactivetools.com/forum/gforum.cgi?post=61466&

So, maybe it's just a monday and my brain is still on the weekend... here's what I did:

Here's my header form code: (search field is at the top of each page)

<form method="post" action="search.php">
<input name="content" type="text" value="" size="13">
<input type="submit" name="submit" value="Go!">
</form>

I'm attaching the search.php page but all it is a list page I created named "search" since I don't currently have a listViewer.php page... maybe that's the issue. I'm just confused now. Help would be greatly appreciated. Thanks!! Tina
Attachments:

search_007.php 7K

Re: [csdesign] Adding a viewer Search Engine

By Jason - April 5, 2011

Hi Tina,

From the sounds of it, you want to return records that have the text typed in the text box somewhere in the content field. Is that right?

If so what you'll need to do is add "_keyword" to the end of your text box name like this:

<form method="post" action="search.php">
<input name="content_keyword" type="text" value="" size="13">
<input type="submit" name="submit" value="Go!">
</form>


So with this code, your page will return all the records from the "search" table that have the text typed into the text box somewhere in it's content field.

Hope this helps get you started.
---------------------------------------------------
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] Adding a viewer Search Engine

By csdesign - April 5, 2011

Hi Jason, thanks for the help! I changed the form code. If I want it to search keywords of the content and the titles, is this correct?

<form method="post" action="search.php">
<input name="content_keyword,title_keyword" type="text" value="" size="13">
<input type="submit" name="submit" value="Go!">
</form>


It appears I'm still having an issue with the search.php page.

Doing a search on the world "center" still turns up nothing so I'm obviously missing a big piece of the puzzle here to get the keyword results to display on the search.php page.

The search.php page was attached previously, here's the web view:
http://www.nwsc5872139.myutilitydomain.com/search.php

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


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/services8/webpages/util/n/w/nwsc5872139.myutilitydomain.com/public/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($searchRecords, $searchMetaData) = getRecords(array(
'tableName' => 'search',
'perPage' => '30',
));

?>


++++++++++++++++++++

<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Search - List Page Viewer</h1>
<?php foreach ($searchRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Title: <?php echo $record['title'] ?><br/>
Content: <?php echo $record['content'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>

<hr/>
<?php endforeach ?>

<?php if ($searchMetaData['invalidPageNum']): ?>
Results page '<?php echo $searchMetaData['page']?>' not found, <a href="<?php echo $searchMetaData['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/><br/>
<?php elseif (!$searchRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->


<!-- STEP3: Display Page Links (Paste anywhere below "Load Record List") -->
<?php if ($searchMetaData['prevPage']): ?>
<a href="<?php echo $searchMetaData['prevPageLink'] ?>">&lt;&lt; prev</a>
<?php else: ?>
&lt;&lt; prev
<?php endif ?>

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

<?php if ($searchMetaData['nextPage']): ?>
<a href="<?php echo $searchMetaData['nextPageLink'] ?>">next &gt;&gt;</a>
<?php else: ?>
next &gt;&gt;
<?php endif ?>
<!-- /STEP3: Display Page Links -->


Thank you so much! Tina

Re: [csdesign] Adding a viewer Search Engine

By Jason - April 5, 2011

Hi Tina,

A couple of things to try. If you want to search for multiple fields, you only have to put the _keyword suffix at the end of the list like this:

<form method="post" action="search.php">
<input name="content,title_keyword" type="text" value="" size="13">
<input type="submit" name="submit" value="Go!">
</form>


If that still isn't working, try adding this to your query:

// load records
list($searchRecords, $searchMetaData) = getRecords(array(
'tableName' => 'search',
'perPage' => '30',
'debugSql' => true,

));


This will output your query, so you can see if your search term is being put in properly. Let me know what that outputs.

Finally, go into your "search" section and open up the first record. Look at your content field for that record and pick a word in it. Try doing your search on that word, since you know it should be returning a result.

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] Adding a viewer Search Engine

By csdesign - April 5, 2011

thanks Jason... Yes, I'm a pain today - thanks for you patience! :)

I changed the code to the ones you sent me. I think the problem lies in that I'm attempting to use the search.php page as the output page so I set it up as a list page but yet it has no content... I'm expecting the search results to go here and I'm sure that's where the fault is at.

I get this code at the top of my search.php now:

SELECT SQL_CALC_FOUND_ROWS `search`.*
FROM `cms_search` as `search`

ORDER BY title
LIMIT 30

Re: [Jason] Adding a viewer Search Engine

By csdesign - April 6, 2011

OH see... that's the part I've been missing - wow.. it's so obvious now.

I was not setting up the search tab in the editor. I hope that's some kind of classic newbie mistake. :)

I setup the "searching" tab as seen in this screenshot, but I get all the same results.

Also, I have the search form field in the include header of every page - not in the body of the "search.php" page

thanks a ton! Tina
Attachments:

picture-5_002.png 118K

Re: [csdesign] Adding a viewer Search Engine

By Jason - April 7, 2011

Hi Tina,

The search tab is for setting up searches within CMS Builder, not for front end pages. I think the issue is that your "search" section doesn't have any records in it. Which CMS Builder section are you trying to search?

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] Adding a viewer Search Engine

By csdesign - April 7, 2011

I want it to search all sections (pages) of the website

Re: [csdesign] Adding a viewer Search Engine

By Jason - April 7, 2011

Hi,

Okay, in that case you would need to use the multiSearch search in order to do this. The getRecords function only searches against 1 section at a time. If you're having trouble implementing this, we can help you set this up through consulting. If you're interested in this, please email consulting@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/