Search Engine and List Page Display

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

Re: [Duches77] Search Engine and List Page Display

By Jason - April 14, 2011

Hi Jessica,

Yes, a good way to do this is to put your query inside an if statement checking for a value in the $_REQUEST array. I usually use a hidden field that I call "formSubmitted" to detect whether or not they've done the search.

Here is an example of how it could work. In your form, you would have something like this:

<form method="post" name = "doctorSearch" action = "?" >
<input type = "hidden" name = "formSubmitted" value = "1" />


Then up at the top of your page you could do this:

if (@$_REQUEST['formSubmitted']) {

list ($doctorRecords, $doctorMetaData) = getRecords(array(
'tableName' => 'doctors',
));
}
else {

$doctorRecords = array();
}


That way when they go to this page, if they haven't used your form, no records will be returned.

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] Search Engine and List Page Display

By JLynne77 - April 14, 2011

Wow, that's even easier than my original idea.

Addionally, if I link to the same listing page with the search query in the URL, will it display the listings without submitting the form? or will I need to add "formSubmitted=1" to the URL as well?
-----
~Jessica Sullivan, Crystal Realm Designs.

Re: [Duches77] Search Engine and List Page Display

By Jason - April 14, 2011

Hi Jessica,

In this example, you would need to add "formSubmitted" to the URL. If this is something you need to do frequently, you can remove formSubmitted and use:

if ($_REQUEST) {

instead. This just checks to see if there's something in the request array, it doesn't matter what's in there. This would make it easier linking in from other pages, but doesn't guarantee that a form was submitted.

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] Search Engine and List Page Display

By JLynne77 - April 14, 2011 - edited: April 14, 2011

I seem to be hitting a block. I have:
if ($_REQUEST) {
// load records if there is a search variable
list($find_a_doctorRecords, $find_a_doctorMetaData) = getRecords(array(
'tableName' => 'find_a_doctor',
));

} else {
// or do not load any records
$find_a_doctorRecords = array();
}



I did not add the hidden field to the form as we're not using it. The page loads properly for no form selection and having the search keyword in the URL, but not when I select something from the search form. I get a blank page.

Page is here... The drop downs are the search form. The letter graphics are loading the search parameter from the URL.

edit updated code and page URL





edit2 for the sake of keeping my hours down for the sake of the client's billing, I've decided to use separate pages for the search form and the results list. Thank you for your help, though.
-----
~Jessica Sullivan, Crystal Realm Designs.

Re: [Duches77] Search Engine and List Page Display

By Jason - April 15, 2011

Hi Jessica,

Okay, I hope that works out for you. One thing I did notice, is that if you only selected from 1 drop down, you got result, but not when you selected from both. This is because selecting from both makes your search more restrictive, so it's more likely that you're not going to return a result. One this you can try is put your drop downs in separate forms, and put the words "OR" on your form so people know that they are searching for either one or the other.

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] Search Engine and List Page Display

By JLynne77 - April 15, 2011

The lack of results could be because, for testing, we do not have the entire Doctor's database entered into the system. I know which combinations will get results. If you pick "Internal Medicine" and "GHI", you'll get results. It's going to end up being a database of a couple hundred doctors, but I'm trying to get things to work before entering them all in. That way, if any changes have to be made to the way the CMS forms are set up, we don't have to go back and change several hundred doctors in case lists needed to be re-entered, but rather, only a small set. One thing I have noticed that can be quite tedious when you have a lot of records is that, when you edit anything in a list, you have to go back through and update the list selections for every single record.
-----
~Jessica Sullivan, Crystal Realm Designs.

Re: [Duches77] Search Engine and List Page Display

By Jason - April 18, 2011

Hi Jessica,

I am a little unsure of what you mean when you say you have to "update the list selections for every single record". Are you using a separate section to store your list? Are you referring to when you add a new record to a list, or when you change the name of something in the list?

If you're using a separate section for your list, a good practice is to use the "num" field as an option value. That way, if you ever go back into a record in your list and change anything, the num field will remain the same, so you won't have to update any records where that was selected.

Here are some instructions for setting that up:
http://www.interactivetools.com/forum/gforum.cgi?post=87356#87356

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] Search Engine and List Page Display

By JLynne77 - April 19, 2011

That's an interesting idea, and might make it easier to allow the client to update the list themselves. I have some more specific questions that I've put in the other thread since they fit better there.
-----
~Jessica Sullivan, Crystal Realm Designs.