Help needed, please, to get started with Search...

10 posts by 4 authors in: Forums > CMS Builder
Last Post: March 18, 2009   (RSS)

Re: [Itsnoprob] Help needed, please, to get started with Search...

By Kenny - March 16, 2009

Nigel,

First things first - change your characher set from charset=windows-1252 to charset=utf-8

This will prevent future problems....

Now for searching problem - I would need to see your code to diagnose this problem.

One question though - why have a page called Search_Results.php? If you are trying to search an FAQ page, all you have to do is build the main page of the FAQ.

Example:

Question
Answer

Then build a search page (or include it on the same page) that searches your main page for FAQ. There is no reason to create a search results page. The search results will be pulled from the main page.

I hope that makes sense. If not, post your code here and we can go from there.

Kenny

Re: [sagentic] Help needed, please, to get started with Search...

By Itsnoprob - March 16, 2009 - edited: March 16, 2009

Hi Kenny,

Thanks for the reply...

I note your point about [font "Verdana"]charset=utf-8 (but I don't know why?)

[font "Verdana"]I hope the code info below gives you what you need to point me in the right direction.....

My main page for FAQs is http://www.itsnoprob.co.uk/Content_Management_System_FAQs.php which has questions and answers as you laid out.

The code for my Search Page currently - http://www.itsnoprob.co.uk/Search.php - is just:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
</head>

<body>
<form method="GET" action="http://www.itsnoprob.co.uk/Search_Results.php">
<input type="text" name="answer_keyword" value="">
<input type="submit" name="submit" value="Search">
</form>


</body>

</html>



The code for my results page currently - http://www.itsnoprob.co.uk/Search_Results.php - is:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
</head>

<body>
<!-- STEP1: Load Record (Paste this above other step) -->
<?php
require_once "/home/itsnoprobuk/public_html/cmsAdmin/lib/viewer_functions.php";
$options = array(); // NOTE: see online documentation for more details on these options
$options['tableName'] = 'faq'; // (REQUIRED) MySQL tablename to list record from. Example: "article";
$options['recordNum'] = ''; // (optional) Record number to display. Example: "1"; Defaults to number on end of url, then 1
$options['where'] = ''; // (ADVANCED) MySQL WHERE conditions to use INSTEAD of recordNum to look up record. Example: "fieldname = 'value'"
$record = getRecord($options);
?>
<!-- /STEP1: Load Record -->

<!-- STEP2: Display Record (Paste this where you want your record displayed and re-arrange fields) -->
<h1>FAQ Page Viewer</h1>
<?php if ($record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Question: <?php echo $record['question'] ?><br/>
Answer: <?php echo $record['answer'] ?><br/>
Sort (optional): <?php echo $record['sort'] ?><br/>
<?php endif ?>

<?php if (empty($record)): ?><!-- Display "No Records Found" Message -->
No record found!<br/><br/>
<?php endif ?>
<!-- STEP2: /Display Record -->

<!-- STEP3: Display Uploads from 'upload' (Paste this where you want your uploads displayed) -->
<!-- Upload Program Fields : num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath -->
<!-- Upload Image Fields : isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight -->
<!-- Upload Info Fields : info1, info2, info3, info4, info5 -->
<?php if ($record): ?>
<?php foreach (getUploads($options['tableName'], 'upload', $record['num']) as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<?php endif ?>
<!-- STEP3: /Display Uploads from 'upload' -->

<div style="float: right; font-size: 10px; color: #999999">
<a href='http://www.interactivetools.com/'>Content Management</a> by interactivetools.com<br/><br/>
</div>

</body>

</html>

I 'know' this is totally wrong but I'm going round in ever decreasing circles trying to understand why??


Thanks, Nigel
http://www.Itsnoprob.co.uk

Personal Service on the Net!

Re: [Itsnoprob] Help needed, please, to get started with Search...

By ross - March 16, 2009

Hi Nigel

Thanks for getting that extra code up there. For now though, my first thought is going to be the same as Kenny's.

You can actually use your main FAQ page as the results page instead of having two different pages. This will cut down on all the extra work you end up having to do while maintaining two pages that actually just do the same thing.

So the first change you want to make is on Search.php. Change the forms action to your main FAQ page like this:

<form method="GET" action="/Content_Management_System_FAQs.php">

Get that going first and then we'll have a closer look from there.

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Help needed, please, to get started with Search...

By Itsnoprob - March 16, 2009 - edited: March 16, 2009

Hi Ross,

Initial change made as requested to http://www.itsnoprob.co.uk/Content_Management_System_FAQs.php, although this is a multi-page section and answers are on http://www.itsnoprob.co.uk/faqPage.php

No apparent difference in terms of end result???

Thanks for any help you can give.

Nigel
http://www.Itsnoprob.co.uk

Personal Service on the Net!

Re: [Itsnoprob] Help needed, please, to get started with Search...

By Itsnoprob - March 17, 2009

I have been having a think about this....

The online documentation is pretty clear about setting up a simple 'keyword' search box.

Perhaps the easiest way to 'sort me out' would be if someone would be good enough to supply example code for a results page that works rather than trying to sort out the mess I've got myself into????

Many thanks,

Nigel
http://www.Itsnoprob.co.uk

Personal Service on the Net!

Re: [Itsnoprob] Help needed, please, to get started with Search...

By ross - March 17, 2009

Hi Nigel

Thanks for getting back in touch. We are talking about two different pages now though, and I am not quite sure how you have this setup.

Are you saying one page lists all the questions and the other page lists all the answers?

Also, it looks like the account you are using to connect CMS Builder to your database has been changed so your pages don't actually work right now. You'll need to contact your webhost and ask them to adjust the account so it can access the database again.

Let me know and we'll go from there. Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Help needed, please, to get started with Search...

By Itsnoprob - March 17, 2009

Yes to the first question, Ross.

I have been trying to fix today and got even more screwed up - the system should now be up and running again

Cheers,

Nigel
http://www.Itsnoprob.co.uk

Personal Service on the Net!

Re: [Itsnoprob] Help needed, please, to get started with Search...

By Dave - March 17, 2009

Hi Nigel,

I noticed on your search_results.php code you posted that you're using a older version of CMS Builder. I'd recommend upgrading or if you already have upgraded then re-creating the code from the code generator.

>supply example code for a results page that works

There's almost no difference between a regular results page like you have here that lists all records:
http://www.itsnoprob.co.uk/Content_Management_System_FAQs.php

And a "search" results page. The only difference is when you a submit a search form with specially named fields (as described in the search docs here: http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html) it limits the results.

Here's an example link that searches for news:
http://www.itsnoprob.co.uk/Content_Management_System_FAQs.php?answer_keyword=news

So to create a search results page you just create a regular list page and point your search form at it.

Hope that helps, let me know if ou have more questions.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Help needed, please, to get started with Search...

By Itsnoprob - March 18, 2009

Thank you very much!

I cannot believe, now that you've shown me, what a meal I was making out of this!

Thanks again,

Nigel
http://www.Itsnoprob.co.uk

Personal Service on the Net!