Saturday, March 20, 2010

How to Build Your Own Web Content Management System

Building your own Content Management System (CMS) will allow you to successfully implement thousands of websites and intranets. Customizing such websites and content systems will not only be easy and quick but can also be done using commonly available tools such as PHP. Since a CMS uses a design process supported by object-oriented programming, the code can be kept neat and tidy by bundling it together in files called classes. Objects or instances of these classes are then created as needed. Classes thus act like blueprints for instances making it possible to design a large number of systems with minimal code afterwards.

Instructions
  1. Step 1

    Create a database. This is where all the login and data information will be stored. Such a database would include setting up a customer's table and other information. Using a database will help you to organize information logically, rapidly gain access to it, manipulate and change it whenever needed and automate common tasks more easily.

  2. Step 2

    Create a class for accessing the database. Such a class will tell the program to grab data and components from a system component and provide access to it. The example below shows the functional approach in using such a class:

    Class: DbConnector
    // Purpose: Connect to a database, MySQL

    require_once 'SystemComponent.php';
    class DbConnector extends SystemComponent {

    include variables here
    }
    function DbConnector(){

    $user = $settings['dbusername'];
    $pass= $settings['dbpassword'];
    }
    function query(){

    code goes here
    }
    function fetchArray(){

    code goes here
    }
    function close(){
    mysql_close();
    }

    The above code shows the main parts of the database and how to connect and retrieve data from it.

  3. Step 3

    Create a validator class for security. A validator class checks for errors in user input and will either display an error or allow a user login if it is safe and correct. An example of such a class written in PHP is shown below:

    require_once 'SystemComponent.php';
    class Validator extends SystemComponent {

    var $errors;
    }
    ?>

    The above code stores a list of error messages.

  4. Step4

    Write a class to secure the site. The function for doing this is shown below:

    Function logg(){

    session_start()
    Header("cache-control: private");
    }

    function logout(){

    unset($this->userdata);
    session_destroy();
    exit();
    }

  5. Step 5

    Create the interface design. This is graphical part of the site with the login information as well as other additional information generally appearing on the homepage.

  6. Step 6

    Create the help and documentation for the system to address the most common tasks a user will need to perform.

No comments:

Post a Comment