MySQL
  Home arrow MySQL arrow Page 7 - Building a Simple ColdFusion Content Management System with MySQL
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
MYSQL

Building a Simple ColdFusion Content Management System with MySQL
By: Charles Kaufmann
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 46
    2004-08-11


    Table of Contents:
  • Building a Simple ColdFusion Content Management System with MySQL
  • Starting With MySQL
  • The Page and how to Update/Modify and Delete
  • Add/Modify Form
  • Action
  • Breadcrumb List
  • Side Menu
  • Site Map

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Building a Simple ColdFusion Content Management System with MySQL - Side Menu
    ( Page 7 of 8 )

    As I stated above, this menu is designed to show up on the side of the page, and that it will expand if you are within a subsection of the home page. For example if your web site had several major sections, Carpentry and Stamp Collecting. If someone clicked on Stamp Collecting, all of the child pages would expand (similar to browsing for files, you click on a folder and the sub folders become visible).

    Let look at the code. You can either include this in the menu section of your site or create a new page with this code and CFINCLUDE it in.

    1  <cfparam name="baseid" default="1">
    2  <cfquery name="menusub" datasource="#variables.data#">
    3    select *
    4    From tblpages
    5    Where status='A'
    6    Order by hierarchy
    7  </cfquery>
    8  <cfoutput query="menusub">
    9   <cfif listlen(menusub.hierarchy, "~") gt 1>
    10   <cfif listgetat(menusub.hierarchy, 2, "~") eq baseid>
    11     <cfloop from="2" to="#listlen(menusub.hierarchy, "~")#" index="i">
    12  -
    13   </cfloop>
    14    <a target="_self" href="page.cfm?id=#menusub.id#" 
    15    title="#title#">#title#</a><br>
    16   <cfelseif level eq 2> <!--- NON EXPANDED MENU --->
    17    - <a target="_self" href="page.cfm?id=#menusub.id#"
    18   title="#title#">#title#</a><br>
    19   </cfif>
    20  <cfelse> <!--- HOME --->
    21  <a target="_self" href="page.cfm?id=#menusub.id#"
    22  title="#title#">#title#</a><br>
    23  </cfif>
    24 </cfoutput>

    So now let's walk through the above section of code. I create a CFPARAM for the baseid variable and set its default to 1. This is so you can run pages that you may create that do not run off of this content management system. Due to the fact that it does not run off the content management system it will not have a baseid. The CFPARAM keeps it from throwing an error.

    The CFQUERY on lines 2 through 7 queries out all of your active records and order them by the HIERARCHY field. Line 8 starts the CFOUTPUT of the menu listing. Line 9 starts a CFIF that checks the length of the hierarchy list. If the length is 1 then it is the home page which is dealt with on lines 20 to 23. Line 10 gets back to a variable we created while making the breadcrumb list, the Baseid. We use this variable to check to see if the child off of the homepage is part of the hierarchy you are looking at. If so we are going to expand all the child links from the page with the Baseid. All of the other pages that have a hierarchy level 2 that are not the baseid, will not expand their child pages . If you did not want this to happen you could take out the CFIF and its parts out of line 10. Lines 11 through 13 are just for decoration. That section loops through the hierarchy list length and shows the dashes accordingly. In the CFLOOP I started with 2 in the FROM attribute so that the child pages of the home page would not have a dash in front of them. You could put anything you want in this loop, even spaces. Lines 14 through 15 build the link by using the title and the ID of the record. Lines 16 through 19 finish off the CFIF statement by showing the child pages off of the home page without expanding them. Lines 20 to the end simply display the link for the home page. For this one, since you know exactly what the page is going to be, instead of querying out the title, you could manually code the name (e.g. your site name or use an image).

    That is it for the side menu, the breadcrumb list and also the page itself. As an added bonus however, I am going to throw in a self building site map.



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

       

    MYSQL ARTICLES

    - MySQL Security Tips
    - Designing a MySQL Database: Tips and Techniq...
    - The Three Most Important MySQL Queries
    - Null and Empty Strings
    - MySQL Server Tuning Tips and Tricks
    - MySQL Query Optimizations and Schema Design
    - MySQL Benchmarking Tools and Utilities
    - MySQL Benchmarking Concepts and Strategies
    - Take Some Load off MySQL with MemCached
    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek