Configuration File

We'll create a common configuration file called config.php to define where files are located, the name of the blog, and other basic configuration parameters. This is similar to the way your database connection information is stored in the db_login.php file.

Example 17-1 shows what it looks like.

Example 17-1. The config.php script defines settings that are used throughout the site <?php

// put full path to Smarty.class.php require('/usr/share/php/Smarty/Smarty.class.php'); $smarty = new Smarty();

$smarty->template_dir = '/home/www/htmlkb/smarty/templates';

$smarty->compile_dir = '/home/www/htmlkb/smarty/templates_c'; $smarty->cache_dir = '/home/www/htmlkb/smarty/cache'; $smarty->config_dir = '/home/www/htmlkb/smarty/configs';

$blog_title="Coffee Talk Blog"; ?>

We use /home/www/htmlkb/smarty as our path to the template engine files, but your path will be different based on where you installed Smarty. Note that all the template files go into the directory that $smart->template_dir points to. We also set the name of the blog to "Coffee Talk Blog." We're going to discuss templates for pages, which is similar to having a CSS stylesheet, yet different. Templates, like a CSS stylesheet, will enable your blog to have a consistent look and feel.

Was this article helpful?

0 0

Post a comment