Get Smarty

Donate

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap glasses from Cheapglasses123.com and save up to 80%.

Where to buy prescription glasses? EyewearCanada.com is your best choice!

Visit www.sport-kick.com for cheap soccer cleats, sneakers and Soccer Jerseys updates

Advertisement

Extended Setup

This is a continuation of the basic installation, please read that first!

A slightly more flexible way to setup Smarty is to extend the class and initialize your Smarty environment. So instead of repeatedly setting directory paths, assigning the same vars, etc., we can do that in one place.

Lets create a new directory /php/includes/guestbook/ and make a new file called setup.php. In our example environment, /php/includes is in our include_path. Be sure you set this up too, or use absolute file paths.

Teladan 2-10. /php/includes/guestbook/setup.php

Smarty(); $this->template_dir = \'/web/www.example.com/guestbook/templates/\'; $this->compile_dir = \'/web/www.example.com/guestbook/templates_c/\'; $this->config_dir = \'/web/www.example.com/guestbook/configs/\'; $this->cache_dir = \'/web/www.example.com/guestbook/cache/\'; $this->caching = true; $this->assign(\'app_name\', \'Guest Book\'); } } ?>'); ?>

Now lets alter the index.php file to use setup.php:

Teladan 2-11. /web/www.example.com/guestbook/htdocs/index.php

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

Now you see it is quite simple to bring up an instance of Smarty, just use Smarty_GuestBook() which automatically initializes everything for our application.

Comments
No comments for this page.

Advertisement