more info

Media72 Hosting Articles and Tips

Archive for September, 2006

Smarty Template Engine Support

Sunday, September 3rd, 2006

Due to popular demand we have added Smarty Template Engine support to our servers. Smarty is a popular template engine written in PHP which allows you to easily separate code logic from presentation.

How to use Smarty

Using Smarty on our servers is easy. Firstly you need to FTP into your account and create some folders located outside of your website root. First make a folder called "smarty" in your user folder, inside of this create the following folders:

templates
templates_c
cache
configs

Once you have created your folders you will need to change the permissions on the "templates_c" and "cache" folders to 775 so they are writable, you should be bale to do this using your FTP client. You are now ready to start using smarty, create an index.php file with the following code and upload it to your public_html folder, make sure to replace "username" with your actual username.

<?php

require('Smarty/Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = '/home2/username/smarty/templates';
$smarty->compile_dir = '/home2/username/smarty/templates_c';
$smarty->cache_dir = '/home2/username/smarty/cache';
$smarty->config_dir = '/home2/username/smarty/configs';

$smarty->assign('name', 'Ned');
$smarty->display('index.tpl');

?>

Now open up your browser and point it to your website address, you should now see the text "Hello, Ned!". Thats it, you now have Smarty setup and are ready to go. For more information on using Smarty we suggest starting with the Smarty Crash Course article.

 

hedges