Home arrow Site Administration arrow Page 4 - Building a Barebones Content Management System: An Introduction

Setting it up - Administration

How do you keep visitors returning to your website? By updating content regularly. Maintaining this gets out of hand unless you have a content management system. Harish Kamath explains how to put a barebones CMS together using three APIs.  To see the VIDEO TUTORIAL click HERE.

  1. Building a Barebones Content Management System: An Introduction
  2. yaapi and patTemplate and patUser = A barebones CMS
  3. Getting Started with yaapi
  4. Setting it up
  5. First Glance
By: Harish Kamath
Rating: starstarstarstarstar / 15
September 14, 2005

print this article
Building A Barebones CMS - Video Tutorial


Free companion video tutorial for this article! Click Here!


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:


// 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.


* 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.


// Core library and configuration files

// 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 Site Administration Articles          >>> More By Harish Kamath

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Coding: Not Just for Developers
- To Support or Not Support IE?
- Administration: Networking OSX and Win 7
- DotNetNuke Gets Social
- Integrating MailChimp with Joomla: Creating ...
- Integrating MailChimp with Joomla: List Mana...
- Integrating MailChimp with Joomla: Building ...
- Integrating MailChimp with Joomla
- More Top WordPress Plugins for Social Media
- Optimizing Security: SSH Public Key Authenti...
- Patches and Rejects in Software Configuratio...
- Configuring a CVS Server
- Managing Code and Teams for Cross-Platform S...
- Software Configuration Management
- Back Up a Joomla Site with Akeeba Backup

Developer Shed Affiliates


Dev Shed Tutorial Topics: