Multi table search

6 posts by 5 authors in: Forums > CMS Builder
Last Post: August 3, 2010   (RSS)

By willydoit - May 11, 2010

Hi all,

I have a site which provides accommodation listings and comprises of a table for each accommodation type, ie Hotel, Guest House, Self Catering, Holiday Park etc all my searches etc work fine on their own pages however I would like to give the accommodation more prominence on the index page so want to include a basic search facilty which would direct the viewer to the listing page for that type of accommodation.

My first question is can I perform a search from a html page (index.html) as I dont want to have to change the index page name to php.

Secondly what is the simplest method to simply provide a drop down box showing accommodation types to select from and then direct the viewer to the listing page for that specific accommodation type. I know its basically just a menu choice which could be provided with hyperlinks but I want the facility to look like a search facility to get it to stand out more but in reality there wouldnt need to be an actual search as each option could be hardcoded such as http://www.bridlington.net/listings/serviced_list.php?accommodation_type=Hotel .

If I have to do a proper search how easy is it to search on multiple tables, I have taken a look at multisearch.php but at first glance it seems far more complex than I need.

I know there is probably lots of simple options to make it look like a search but I am afraid at the moment I am pretty much brain dead and need some inspiration if someone could help.

Thanks in advance

Re: [willydoit] Multi table search

By gkornbluth - May 11, 2010 - edited: May 11, 2010

Hi willydoit,

The answer to the first question should be fairly easy.

here's an excerpt from my CMSB Cookbook http://www.thecmsbcookbook.com that describes an approach:

RENDERING PHP CODE ON ".HTML" FILES
This method outlines how you can use PHP code on files created with the ".html" extension.

Create a plain text file called ".htaccess", and add the following line to it:

Addhandler application/x-httpd-php .html .php

Now upload this file to the root web directory on your server. You should now be able to use CMS Builder's code on any page with the ".html" or ".php" extensions. You can even add your own custom extensions to the code above if you'd like, such as ".shtml" or ".htm". This method is ideal for situations where you need to use CMS Builder on a site that currently uses static HTML pages, but would like to preserve the site's existing URL's.


Hope this helps.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Multi table search

By willydoit - May 11, 2010

Thanks Jerry,

I will make a start with that.

Re: Search box - CMS builder

Hi

I've been looking through the forum for a drop down search box, and this solution posted sort of meets my needs, but I was wondering if there's a way to be a bit more "clever". The code you provided is:

<form name="form">

<select name="select" onChange="displaydesc(document.form.select, thetext, 'textcontainer')">
<option selected="" value="">Accommodation Type</option>
<?php foreach ($accommodationsRecords as $record): ?>
<option value="<?php echo $record['_link'] ?>"><?php echo $record['accommodation'] ?></option>
<?php endforeach; ?>
</select>

<input onClick="jumptolink(document.form.select)" type="button" value="Go" />

</form>

<script type="text/javascript">

function displaydesc(which, descriptionarray, container){
if (document.getElementById)
document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex]
}

function jumptolink(what){
var selectedopt=what.options[what.selectedIndex]
if (document.getElementById && selectedopt.getAttribute("target")=="newwin")
window.open(selectedopt.value)
else
window.location=selectedopt.value
}
</script>


However, I wanted to be able to show the search box without the "Go" button, and be able to add a suburb listing within which to group the properties - for example, http://www.fordland.com.au/ (see top right hand corner search). This search box is for the old website and I'm moving it over to a CMS builder. Is this possible? Any suggestions.



thanks

Re: [degreesnorth] Search box - CMS builder

By Jason - August 3, 2010

Hi,

From the sounds of it you want to be able to do 2 things. First, be able to group drop down options. There is a tag called <optgroup> that will allow you to do that. See here for more information on how that tag works:
http://www.w3schools.com/TAGS/tag_optgroup.asp

As for the second issue, it sounds like you want to have the list box execute the same code that the submit button does when its value changes. You can do this by calling the same event that the submit button does. Try changing the code like this:

<select name="select" onChange="displaydesc(document.form.select, thetext, 'textcontainer'); jumptolink(document.form.select);">

Hopefully 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/