Home arrow MySQL arrow Page 3 - Building a Simple ColdFusion Content Management System with MySQL

The Page and how to Update/Modify and Delete - MySQL

This tutorial lays out the basics for creating a content management system in ColdFusion and MySQL. The System leverages hierarchical data to automatically build breadcrumb lists, a side navigation menu, as well as a site map. The goal of this tutorial is to provide a framework upon which to build a content management system that is easy to customize and maintain, leaving the web author more time to create content than maintain code.

TABLE OF CONTENTS:
  1. Building a Simple ColdFusion Content Management System with MySQL
  2. Starting With MySQL
  3. The Page and how to Update/Modify and Delete
  4. Add/Modify Form
  5. Action
  6. Breadcrumb List
  7. Side Menu
  8. Site Map
By: Charles Kaufmann
Rating: starstarstarstarstar / 48
August 11, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

We will now start writing some code to display a page and also to modify add and delete pages. I am going to write the code so that you can put it within the body tags and the entire piece is going to be located on the same page. Let's start out with the CFIF statement that is going to control the whole page. We are also going to set a variable that will specify your data source.

<cfset data = "YourDataSource">
<cfif isdefined("url.mod") or isdefined("url.add")>
<cfelseif isdefined("form.modify")>
<cfelseif isdefined("url.delete")>
<cfelseif isdefined("form.add")>
<cfelse>
</cfif>

So this is the flow of the program. If nothing is specified it is just going to load the page (the CFELSE). But if you are going to add, modify or delete, it will look at that specific area. The way we are going to create the hierarchy is that when you are adding a page, you have to select the add link from the page you want to create the child page off of. For example if you had a page on "building a bird house" and you wanted to create a child page off of it for materials, you would have to go to the "build a bird house" page then click on the add link. What this does is it provides the form with the ID of the parent page so that you can insert it into the PARENTID field.

Show Page

So let's build the CFELSE part (view the page). The first part will be the CFQUERY that will query out the record you are requesting (url.id). The below code is going to set a CFPARAM so that if the page is requested without a URL.ID it will load the home page.

 <cfparam name="url.id" default="1">
  
 <cfquery name="getpage" datasource="#variables.data#">
  Select *
  From tblpages
  where id = #url.id# and status = 'A'
 </cfquery>
 
 <cfoutput>  
   #getpage.body# 
 </cfoutput>

 <!---  Page/Site administration  ---> 
<div align="center">
  <!--- put an if statement around this cfoutput to see if
   you are logged in. --->  
  <cfoutput>
   <a href="page.cfm?mod=#getpage.id#" target="_self">Modify</a> |   
   <a href="page.cfm?add=#getpage.id#" target="_self">Add</a> |    <a href="page.cfm?del=#getpage.id#" target="_self" onclick="return
    confirm('Do you really want to Delete this?')">Delete</a>
  </cfoutput> 
</div>

The only variable you are outputting is the BODY field from the query. This is a Text field that holds all the words and HTML that makes up your page. The next section is for page/site administration. There will be three links at the bottom of the page.

The Modify link is to modify the existing page you are on.
The Add page is to add a child page off of the current page.
The Delete link is to delete the current page.



 
 
>>> More MySQL Articles          >>> More By Charles Kaufmann
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

MYSQL ARTICLES

- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: