Tutorial: CMS Builder Search Engine (Outdated, See Docs for Searching)
10 posts by 4 authors in: Forums > CMS Builder
Last Post: November 1, 2008 (RSS)
By Dave - December 11, 2007 - edited: January 21, 2008
If anyone has a search engine they want to build just post and I'll help you out with it.
Update: This is now outdated. Searching is now built in. See this doc page: http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html
interactivetools.com
Re: [Dave] Tutorial: CMS Builder Search Engine
By aev - December 12, 2007
I have just finished building our first CMS Builder site, and I don't need searching for that site, but I would love to have a tutorial on this, and try it out on a "localhost demo site". This why I can be certain of the possibilities/limitations of this before promising anything to the next CMS Builder customer.
-aev-
Re: [aev] Tutorial: CMS Builder Search Engine
By Dave - December 12, 2007
Start with your standard "List Viewer" that you're using to display your content.
Add the search form at top. Here's a simple one:
<form method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
Keyword: <input type="text" name="keyword" value="" size="15">
<input type="submit" name="" value="Search">
</form>
Next, in the record list loader code, replace the "$options['where'] = ''" line with this code (using your own fields if you don't have title, summary, and content):
$escapedKeyword = escapeMysqlString( @$FORM['keyword'] );
$options['where'] = "title LIKE '%$escapedKeyword%' OR
summary LIKE '%$escapedKeyword%' OR
content LIKE '%$escapedKeyword%'";
This adds on to the WHERE part of the MySQL statement which tells it what records to return. The "LIKE" means "looks like" and the "%" means anything. So it will return record where the title has the title has the keyword in it -OR- the summary -OR- etc. (Don't forget to use your own fieldnames or you'll get an error).
You can also do numeric (greater than, less than) searches and exact match search (show only articles from category X).
Then finally, add this code _below_ the line with getListRows();
$scriptUrl = $_SERVER['PHP_SELF'];
$encodedKeyword = urlencode(@$FORM['keyword']);
$listDetails['prevPageLink'] = "$scriptUrl?keyword=$encodedKeyword&page={$listDetails['prevPage']}";
$listDetails['nextPageLink'] = "$scriptUrl?keyword=$encodedKeyword&page={$listDetails['nextPage']}";
This updates your prev/next links to pass the keyword along when you switch from page to page so you're still only getting filtered results.
So, we haven't automated this part of yet, but it's still possible with a few lines of code. Let me know if it works or if you need more help with it. :)
interactivetools.com
Re: [Dave] Tutorial: CMS Builder Search Engine
By Dave - January 11, 2008
<form method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
Keyword: <input type="text" name="myfield_keyword" value="" size="15">
<input type="submit" name="" value="Search">
</form>
interactivetools.com
Re: [aev] Tutorial: CMS Builder Search Engine
By Theo - January 21, 2008
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html
Re: [Dave] Tutorial: CMS Builder Search Engine
Do you have any sample code for getting the matching results to appear on the listViewer.php (results) page?
Thanks.
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
Re: [NigelGordijk] Tutorial: CMS Builder Search Engine
By Dave - October 30, 2008
If you start with a page that lists "all" the results, the search engine will just filter those. So use a regular list page, and then point your search form at that.
Hope that makes sense, let me know if you need more details.
interactivetools.com
Re: [Dave] Tutorial: CMS Builder Search Engine
I actually needed the tags that displays the results on a search results page. I have a search form on this page that goes to the results page when you click on the submit button: http://www.satoa.com/membersList.php. However, I don't know what to put in the results page code - http://www.satoa.com/listViewer.php - so that the matching results are shown.
Regards,
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
Re: [NigelGordijk] Tutorial: CMS Builder Search Engine
By Dave - October 31, 2008
Start by making this page list "all results":
http://www.satoa.com/listViewer.php
Then it should work. Let me know if you're still having trouble once you get that page displaying all results.
interactivetools.com
Re: [Dave] Tutorial: CMS Builder Search Engine
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net