This tutorial demonstrates how to generate a dynamic sitemap for a ColdFusion database-driven website, assuming that you retrieve the content of your website from a database and you save the website content according to the concept of "Parent" and "Parent ID".
Let's say that you save your website content (through a content management system or a content publishing tool) in the following database table (name it "content" for example). Example:
| ID | PARENT_ID | TITLE | CONTENT | WEIGHT |
| 1 | 0 | Home | Content of this section... | 1 |
| 2 | 0 | Web Development | Content of this section... | 2 |
| 3 | 0 | Contact Us | Content of this section... | 3 |
| 4 | 2 | Macromedia ColdFusion MX | Content of this section... | 1 |
| 5 | 2 | CSS | Content of this section... | 3 |
| 6 | 2 | HTML/XHTML | Content of this section... | 2 |
| 7 | 4 | Tags | Content of this section... | 1 |
| 8 | 4 | Functions | Content of this section... | 2 |
| 9 | 0 | About Us | Content of this section... | 4 |
Now, our dynamic sitemap should look like this (assuming that we order the content by WEIGHT) :
We will need to create two ColdFusion pages, "sitemap.cfm" and "getsitemap.cfm" as the following:
In this page, you just need to include the "getsitemap.cfm" as the following:
<cfinclude template="getsitemap.cfm">
This code helped me with alot of projects, I hope it helps you as well.