Display one's search query

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

By Hansaardappel - August 17, 2011

This may be very easy, but I have no idea how to accomplish it.

I want my search page to look like this:

Search Results for "The search query they entered":

result1
result2 etc...

I got it working as I want, but how do I display the search query?

Thanks!

Re: [Hansaardappel] Display one's search query

By Jason - August 17, 2011

Hi,

Are they entering just 1 search term, or multiple terms? Can you show us the form that they would be filling out to be searching?

Thanks
---------------------------------------------------
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] Display one's search query

By Hansaardappel - August 17, 2011

They can enter whatever they want :) Here's the code I use:

<form method="post" action="search.php">
<input type="text" name="content,title_keyword" id="textfield" value="Search..." />
<button class="btn" title="Submit Search"></button>
</form>

Re: [Hansaardappel] Display one's search query

By Hansaardappel - August 17, 2011

Figured it out already :)

Re: [Hansaardappel] Display one's search query

By Jason - August 18, 2011

Hi,

What must be happening is that your query for $categoryRecords must not be returning a value for record number 2. The most likely reason for this is that your query for $categoryRecords is being affected by your search. You would want to return all records in that query.

You can try using the:
'allowSearch' => false,

option in the getRecords call for $categoryRecords.

If you are using CMS Builder version 2.04 or above, you can skip the $numToName code all together and use the ':label' pseudo field. The code would look like this:

Category: <?php echo $record['category:label'] ?><br/>

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] Display one's search query

By Hansaardappel - August 18, 2011

Worked perfect, thanks!