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.
The form looks like this.
var descriptionObj = null;
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 = head;
this.desc_Arr = 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.
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