![]() |
|||||||||||
|
|
|
|
|
|
|
||||||
![]() ![]() |
Using the Category Anchor Links and Dynamic Named Anchor Server Behaviors These two server behaviors can be used by themselves or together. They do the following: Category Anchor Links: This server behavior retrieves the category information from a recordset to dynamically populate a list of links like this:
Each link will point to a named anchor on the page that has the same name as the link, or a name from another database column. The links can be hard coded on the page, or they can come from the database as well. That's where the second server behavior comes in handy: Dynamic Named Anchors: This server behavior can be used inside of a repeat region to create named anchors based on the content of the database. For example, if you have a list of books in a nested repeat region that contain information about ASP, JSP, CF, and PHP, you could use the Dynamic Named Anchor extension to automatically create the named anchors above each subheading of links. Here is how to apply the two server behaviors: We'll walk through a typical application that uses these server behaviors, as well as another Basic-UltraDev server behavior: Simulated Nested Repeat Region. We'll be using a basic Bookstore database. 1. Add category recordset to the page. We'll call it rsCategories:
The key to the statement is the DISTINCT keyword, which retrieves only one category. If you have your categories in a separate table that's even better. 2. Add the main recordset to the page. We'll call it rsBooks:
The key to using the Simulated Nested Repeat extension is that you have to ORDER BY the column that will make up the outer repeat. 3. Add a four-column, two-row table to the page. Put a title like BOOKS above it and make it a heading, such as H1. Put a place-holder for the Category Anchor Links extension above the table as well. The page should look like this as this point:
4. Add the category field from rsBooks to row 1 column 1. Make it larger font, such as H2. 5. Add the title, description, and price fields to the page to row two cells two, three, and four. 6. Add a repeat region to the table by selecting both rows (but NOT the entire table itself. Select both rows by dragging the cursor across the table cells). The page should look like this at this point:
8. Choose rsBooks recordset and the Category field and click OK. 9. Select row 1 of the table and apply a Simulated Nested Repeat to the row:
If you browse now, the nested repeat should be working properly. 10. Put the cursor at the top of the page where you want the list of category links and apply the Category Anchor Links extension using Recordset1 and the Category field. Choose a delimiter and choose category for both fields. I usually like to use a space, pipe, and space for delimiter:
Now if you browse the page, the category anchors should be clickable and take you down the page to the location of the category.
Click here for live demo of this page. Tom Muck
|