www.SmarteGuru.com
  Home  |  Blogs  |  Find a Friend  |  Discussion Board  |  Resources   |  Developers Area  |  Gallery  |   Login  |  Register Now 
smart Dev Categories
HTML & XHTML Tutorials
CSS Tutorials
JavaScript & AJAX Tutorials
XML, XSLT & Web Services
Linux Side Programming
Ruby on Rails
Apache & IIS Configuration
Server Side Essentials
PHP & MySQL Reviews and Apps
PHP & MySQL Tutorials
PHP & MySQL News & Interviews
Java and J2EE
ColdFusion Tutorials
CGI & Perl Tutorials
ASP & .NET Tutorials
Window Side Programming
smart Dev Home > PHP & MySQL Tutorials

Build an XML-Based Content Management System with PHP

 
By By Tom Myer on July 9th 2003 No of views:

Like most developers, you've probably heard a great deal about XML and content management systems. It's likely, however, that you've only been exposed to theoretical discussions that haven't been grounded in practical knowledge.

This step-by-step tutorial will get you up and running with a very basic XML-based content management system (or CMS). I don't have the space here to get into a very complex example, but with any luck, the concepts and ideas presented here will provide you with the necessary springboard for your own exploration.

Some notes before we get started. I'm using DOMXML functions and sessions to make this application work, so you'll need to use PHP 4.2.1 or higher, and turn on DOM support.

Also, don't forget to download all the codefor this tutorial. It'll come in handy!

A Short Introduction to XML and CMSs

Let me first give you a little background on CMSs and XML. I assume that you've read or heard about both of these technologies elsewhere, so I'll keep this discussion brief.

XML stands for eXtensible Markup Language, and is a subset of SGML (Standardized General Markup Language). XML is very much like HTML, except that in XML you can define your own tags. This ability to produce custom documents comes in very handy when you need to track certain types of data very closely, particularly in the worlds of publishing and ecommerce.

For example, for any given article you publish in an online magazine, you can create tags for author's name, byline (if it's different from the author's name), word length, date of publication, title or headline, story body, keywords, and so on. As you'll see later in this article, breaking your article down into these XML tags or nodes allows the CMS to do useful things with all the articles it holds.

Essentially, XML allows you to make a mini-database out of each document, without the overhead and expense that many databases bring to a Web project.

A CMS is used to create, publish, and maintain content on a Website. It usually consists of the following pieces:

  • A data backend (XML or database tables) that contains all of your articles, news stories, images, and other content.
  • A data display component, usually templates or other pages, onto which your articles, images, etc. are "painted" by the CMS for site visitors.
  • A data administration component, usually easy-to-use HTML forms that allow site administrators to create, edit, publish, and delete articles in some kind of secure workflow. The data administration portion of a CMS is usually the most complicated, and where you'll likely spend most of your development time.

Over the past decade, different scripting languages have been used to create CMSs, including Perl/CGI, ASP, TCL, JSP, Python, and PHP. Each of these languages has its own pros and cons, but I'm going to focus on using PHP with XML to build a simple content management system.

Requirements

Building any kind of CMS, whether database- or XML-backed, involves the gathering of information that defines the basic requirements for the project. Although many developers groan at the thought of this kind of exercise, a set of well-defined requirements can make your life a lot easier.

Because this is a fairly simple project, and because you're going to do it for yourself, a simple requirements list will do.

What kind of requirements do we need to gather? Essentially, requirements fall into three major categories:

  1. What kind of content will the CMS handle? Furthermore, how is each type of content broken down? (The more complete your understanding of this issue, the easier it'll be to create your XML files.)

  2. Who will be visiting the site, and what behaviors do these users expect to find? (For example, will they want to browse a hierarchical list of articles, search for articles by keyword, and see links of related articles?)

  3. What do the site administrators need to do? (For example, log in securely, create content, edit content, publish content, and delete content. If your content management system will have roles for administrative users?such as site admin, editor, writer?then your system becomes more complex).

In the interests of keeping this article from becoming complicated, I will choose very basic requirements for my simple XML-based CMS:

  • The CMS will handle the management of articles only. Each article will have a:
    • unique ID
    • headline
    • author name
    • author email
    • abstract
    • article body that can contain paragraphs and one level of subheading
    • status (either "in progress" or "live")
    • keyword listing

  • Site visitors will be able to view "live" articles listed by author name. They will also be able to perform a search on headline and keywords.

  • The site itself will consist of the following pages:
    • A home page that lists five articles published on the site and a search function.
    • An article detail page that displays one article at a time.
    • A search result page that will list all articles by an author, keyword, or string entered into the search engine.
    • Site administrators get a secure login, a way to add more administrators, and easy screens from which to add new XML files, edit existing files, publish files, and delete files.

? Page 1 2 3 4 5 6
 


Rate this Article :  
Current Rating:
 
Home - About Us - Help - Terms and Conditions - Site Map - Link to Us - Resources - Contact Us
Google Rank Calculator | Suggest developer resource | Suggest Article
All rights reserved © 2007 SmarteGuru.com.