Web Hosting How-Tos

  Home arrow Web Hosting How-Tos arrow Building a CMS, part 2: Taking it to t...
Web Hosting Articles  
Web Hosting FAQs  
Web Hosting How-Tos  
Web Hosting News  
Web Hosting Reviews  
Web Hosting Security  
Weekly Newsletter 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Contact Us 
Site Map 
Privacy Policy 
  >>> SIGN UP!  
  Lost Password? 

Building a CMS, part 2: Taking it to the server
By: Chris Root
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 1

    Table of Contents:
  • Building a CMS, part 2: Taking it to the server
  • Generating the XML
  • Creating the Markup
  • A Word About Namespaces

  • Rate this Article: Poor Best 
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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




    Building a CMS, part 2: Taking it to the server

    (Page 1 of 5 )

    In the first article on this topic, Chris Root discussed the procedure for constructing a simple HTML form-based application to publish a company press release. In this article, he explains how to convert the form output to XML, and how to convert the document to other formats as needed.

    Content management systems (CMS) are a growing software category these days. Sites small and large are using various combinations of commercially available, open source and custom built solutions to manage ever growing content needs for all types of information. Many times a custom built solution is needed, especially when non-technical users are expected to contribute content.

    In my last CMS article I went through the procedure for constructing a simple HTML form-based application to publish a company press release. In this article we will modify and expand the application to include operations on a PHP/Apache back end.

    Specifically, we will be converting our form input, not to HTML but to XML, and using XSL transformations to convert our document to HTML and other formats as needed. Having something such as a press release available in multiple formats would be essential, and having the data stored in a presentation neutral format such as XML is ideal, so let's get started.


    For a brief recap, we have a form-based application that collects data from the user about the press release main heading, date and time, content sub-heading, release content, company description heading (About Company X) and description text, as well as PR contact information and company website address.

    Previously we used Javascript form processing to generate the HTML for a press release page in a new browser window, which could then be saved and emailed to an admin or deposited in a drop box directory for posting on a company website.

    This time we will throw out some javascript code and add some other code specifically for the purpose of sending our data to the server for storage in an XML file.

    Aside from any validation code that may be used, and a function to provide the current date and time, the only Javascript requirement we have is to keep the code we need to compile multiple company descriptions. It was a requirement in our previous version that if Company X was working with Company B on something that was the subject of our press release, we would want to put more than one "About This Company" section in the document. Any HTML generation code is no longer needed.

    The form looks like this.

    For company descriptions we have a custom Javascript description object that holds all the information that is needed for each company description and has methods that allow the user to add, delete and modify descriptions before saving the data to the server.

    var descriptionObj = null;
    function description(head,text)
       this.descHead = "About Company X";
       this.descText = "Company X is a multinational manufacturer" +
        "of widgets for everyday life. Company X spatula division " +
        "ships spatulas to over 60 countries, a list that is expanding" +
        "on a regular basis. Based in Orlando Florida, with offices in " +
        "20 states and affiliates and partners throughout the world blah blah blah.";
       this.desc_Arr = new Array();
       this.head_Arr = new Array();
       this.head_Arr[0] = head;
       this.desc_Arr[0] = text;
       this.addC = addC;
       this.deleteC = deleteC;
       this.restoreDefault = restoreDefault;

    The description object properties descHead and descText are the defaults. There are two arrays that hold multiple headings and description text entries and methods for adding, deleting and restoring the defaults.

    The addC method below will add a description.

    function addC(sel,head,text)
       if(head.value != "" && text.value != "")
          var optobj = document.createElement("option");
          optobj.value = sel.options.length;
          optobj.text = head.value;
          sel.selectedIndex = sel.options.length - 1;
          var hIndx = this.head_Arr.length;
          var tIndx = this.desc_Arr.length;
          this.head_Arr[hIndx] = head.value;
          this.desc_Arr[tIndx] = text.value;
          alert("Please Enter Both a Heading and Text description");

    There is a select menu which displays all company descriptions to the user and allows them to view each one. This method creates a new option for the select menu and adds the new data to the description object. If one of the fields is not filled out it prompts the user to do so. The deleteC method simply reverses this.

    More Web Hosting How-Tos Articles
    More By Chris Root


    - Phishing Scams: An Overview and How to Detec...
    - Tips for Safe Downloading Online
    - How To Avoid Spam
    - How to Get Into Ethical Hacking
    - How to Prevent Drive-by Downloads
    - Facebook Timeline Tips and Tricks
    - How to Keep Up with Facebook`s Changes
    - Wi-Fi Network Security Tips
    - Tips for Safe Online Holiday Shopping
    - Facebook Privacy: Keeping Up with the Const...
    - Tips for Facebook Privacy
    - How to Cover Your Tracks on the Web
    - SSH Keys for FileZilla and Putty in Cpanel
    - How to Create a Filezilla FTP User
    - How to Install FileZilla Server

    Developer Shed Affiliates


    © 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap