Friday, February 24, 2012

Why dont you create your own CMS???--Part 6

For any vehicle to move,it is essential to have an engine.In our 'stupid' cms the 'engine.php' will serve as the engine.
  • Open stupid >>> main folder.
  • create a file and name it as engine.php.
  • create another file and name is as functions.php
  • open 'engine.php' in an editor and write the following code.
The functions.php will contain the simple and essential functions to perform a specific task.
We will complete our functions.php later.For time being we are going to concentrate on our engine.php.
<?php
include_once('functions.php');
include_once('config/base.php');
include_once(CLASSPATH.'/database_class.php');
include_once(CLASSPATH.'/theme_class.php');

global $db,$theme;

$db=new Database();
$theme=new Theme();

/**********************************/

/*******************************/
$theme->load_css();
$theme->load_index();
$theme->load_footer();

/*******************************
*******************************/
?>
Let me briefly describe the code.
First of all we icluded the functions and configuration file.
Then the essential classes were included.
After including the core files,we instantiated the classes using 'new' operator and assigned it to global variable '$db' and '$theme'.Remember the global $db used in theme_class.php.
$db=new Database();
$theme= new Theme();
The database connection will already be made.Now its time to load our theme.The codes
$theme->load_css();
$theme->load_index();
$theme->load_footer();
will do the work for us.I told you "thats the magic of oop".

In the next post we will create our first theme called "default".
It will be easy and great ,if you are familiar with CSS.
Stay tuned...............!

0 comments:

Post a Comment