Creating query result pages
A sample page that provides a query or search feature and displays query results on the same page. One of the most common pages you'll create for viewers to your site is a page that lets viewers search a dynamic content database. For example, a page on a company intranet site might let you search a department's active projects and display the search results on the same page. This section assumes you already have a site created, open, and configured as a dynamic content site (see Making a Web site dynamic). Open a blank page in the site, make it dynamic (see Adding dynamic content and behavior), add a content source to the page (see Understanding content sources), and then proceed as follows. For this example, you'll do the following: - Create two forms on the same page.
- Modify a content source.
- Create a text input area.
- Create a Submit button.
- Make a dynamic content table.
- Make an Edit button that takes you to a page displaying the details for the selected project.
The first area of the page is a search area that lets a viewer search through a database.
To create the search area of the page: - Drag the Form object from the Forms set of the Objects palette to the Layout Editor.
- Open the head section of the document window, and select the Content Source object.
- In the Filters area of the Content Source Inspector, select the field you want viewers to search by, and enter the following in the filter entry box: like '%{Request.QueryString("keyword")}%'
For PHP, enter like '%{pageParameter("keyword","")}%' For JSP, enter like '%{gl.pageParameter("keyword","")}%' - Drag the Text Input object from the Forms set in the Objects palette.
- In the Text Input Inspector, give the text input the name keyword and the value <%=Request.QueryString("keyword")%>
For PHP, enter <?php echo pageParameter("keyword","")?> For JSP, enter <%=gl.pageParameter("keyword","")%> - Drag the Submit Button object from the Forms set of the Objects palette to the right of the text input field.
To create the results area of the search page: - Drag the Form object from the Forms set of the Objects palette to the Layout Editor, just below the first form.
- Drag the Repeat Rows object from the Dynamic Content set of the Objects palette to the second form you just created.
- On the Dynamic Bindings palette, click Bind To, and select your content source from the Content Source pop-up menu.
- Enter any desired labels and placeholder values for each cell in the table.
- Bind each placeholder to the desired fields in your content source.
You might want the viewer to be able to edit a record that appeared in the search results area of the page. Here's a simple way to provide that functionality.
To create an Edit button: - Add a cell to the right of the last cell in the table you created in the second form area.
- Type the word EDIT in the cell, and select it.
- In the Text Inspector, link the text to your details page (if you don't have one, just add a blank dynamic page to your site.
- In the Dynamic Bindings palette, set the Show Details of Current Record link action.
Although designing a query or search page requires some server scripting and knowledge of SQL, the search page described here gives you a simple prototype that you can use and modify for your own site.
|