Administration
  Home arrow Administration arrow Page 4 - Building a Barebones Content Managemen...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
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? 
ADMINISTRATION

Building a Barebones Content Management System: An Introduction
By: Harish Kamath
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2005-09-14

    Table of Contents:
  • Building a Barebones Content Management System: An Introduction
  • yaapi and patTemplate and patUser = A barebones CMS
  • Getting Started with yaapi
  • Setting it up
  • First Glance

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      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 Barebones CMS - Video Tutorial
     
    ADVERTISEMENT

    Free companion video tutorial for this article! Click Here!

    Building a Barebones Content Management System: An Introduction - Setting it up
    (Page 4 of 5 )

    After setting up the database in the previous section, I proceed to configure yaapi itself. For starters, I need to configure obvious parameters such as the database server, the database name, and so on, so that yaapi can retrieve information from the database that I’ve just created above.

    No sweat; locate a file titled "article.class.php" in the root folder of the application and search for the following code snippet:

    <?php

    // snip

    /**
    * object constructor
    */

    function article() {

      $this->version = '1.2.1';

      $this->auto_approve_insert = 0; //bool
      $this->auto_approve_update = 0; //bool
      $this->show_approved_only  = 1; //bool
      $this->show_section_only   = 1; //bool
      $this->hide_intro          = 0; //bool
      $this->use_fix_date        = 1; //bool
      $this->section_id          = 0; //int
      $this->word_wrap           = 0; //width, 0 disables
      $this->allowed_tags        =
      '<a><b><i><u><ol><ul><li><br><p><blockquote>'; //string
      $this->intro_delim         = '#intro#';
      $this->page_delim          = '#page#';
      $this->a_table             = 'article';
      $this->ac_table            = 'article_content';
      $this->cat_table           = 'article_category';

      @$this->link_id = mysql_connect('localhost', 'bb_cmsuser', 'password_comes_here') or die('Could not connect');
      @mysql_select_db('bb_cms') or die('Could not select DB');

    }

    // snip

    ?>

    As the comment suggests, the above code snippet represents the constructor of the yaapi "article" class. For the uninitiated, the term "constructor" is just a fancy term for a function that gets things moving as far as objects are concerned. It’s obvious that this is where I can configure almost all aspects of the application; for the moment, let’s stick to the default values.

    As you might have guessed, the next two of lines of code are of immediate interest as this is where the API initializes a connection to the database. Here I have to specify the server name (i.e. "localhost" in my case), the database username (i.e. "bb_cmsuser") and password (specified at the time of user creation) as well as the name of the database (i.e. "bb_cms") that I intend to use.

    However, I was not comfortable with the idea of specifying these parameters in this file. After all, it will be cumbersome to modify these values when you move your application to a different server. So, I decided to develop a quick work around for this problem by creating a separate configuration file -- titled "inc.config.php" -- to store my instance specific information.

    <?php

    /**
    * Configuration file
    *
    */


    /**
     * Database parameters
     */
    $DBHOST = "localhost";
    $DBNAME = "bb_cms";
    $DBUSER = "bb_cms_user";
    $DBPASS = "password_comes_here";

    ?>

    Next, I update the "article.class.php" file to include this configuration, to ensure that I can access these parameters via the $GLOBALS variable, as demonstrated below.

    <?php

    // Core library and configuration files
    require_once("config.inc.php");

    // snip

    @$this->link_id = mysql_connect($GLOBALS["DBHOST"], $GLOBALS["DBUSER"], $GLOBALS["DBPASS"]) or die('Could not connect');
    @mysql_select_db($GLOBALS["DBNAME"]) or die('Could not select DB');

    // snip

    ?>

    That’s much better, isn’t it? Time to move on.

    More Administration Articles
    More By Harish Kamath


       · Looking forward to the rest of the articles in this series. It would be great if you...
       · Hi,:lol: This tutorial has excellent timings. Good work Harish..Regards
       · Yes - this is a good point. By default, yaapi allows you to add a single image to...
       · hi, I'm wondering what you mean by execute command in the 3 last line. what am I...
       · Hi,With respect to your query, you have to execute the command from the command...
       · Hi, thanks the help. I'm getting an error when I try to run that line. I've tried...
     

       

    ADMINISTRATION ARTICLES

    - Configuring Load-Balanced Clusters
    - Load-Balanced Clusters
    - UNIX Time Format Demystified
    - Making Changes in the CVS
    - Building Your First CVS Repository
    - CVS Quickstart Guide
    - Authorizing Users in Samba
    - Handling User Accounts in Samba
    - Authentication in Samba
    - Accounts, Authentication, and Authorization
    - Advanced Concepts on Dealing with Files and ...
    - Dealing with Files and Filesystems
    - More Hacks for the User Environment in BSD
    - Personalizing the User Environment in BSD
    - Customizing the User Environment in BSD




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway