TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-21-2007, 07:04 PM   #1 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default How to install smarty

Smarty is a known template engine. It has expanded library of functions to help you remove your template from the code .

To use Smarty as a standalone tool and avoid installing it server-side. Follow the steps below:
  1. Download the latest stable Smarty release http://smarty.php.net/download.php
  2. Create templates_c, templates and configs folder in your PHP project root directory
  3. Copy all the files and folders from the libs folder which came with Smarty package
  4. Paste the files and folders to the root directory of your PHP project where templates, templates_c and configs folder resides.
  5. Voila, you're done!

Now to test if Smarty is working.

First, create index.php and save it with the code below:

PHP Code:
<?php

// load Smarty library
require('Smarty.class.php');

$smarty = new Smarty;

$smarty->assign('name','fish boy!');

$smarty->display('index.tpl');

?>
Then, create index.tpl in the templates folder:

HTML Code:
<html>
<body>
 Hello, {$name}!
</body>
</html>
If it renders Hello fish boy then Smarty is successfully connected. :)
Haris is offline  
Reply With Quote
Old 09-21-2007, 07:45 PM   #2 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Awesome :D

However I would like to learn how to create an own template engine/class, similar to the smarty one. Do you know how to achieve it? Any tutorial/article? Perhaps you can make a tutorial about it?
Tanax is offline  
Reply With Quote
Old 09-22-2007, 01:20 AM   #3 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

I had a quick look to smarty and found it excellent but after reading reviews, it has come to my attention that Smarty cons are more heavier than its pros.

1. You have to learn a new language called Smarty. (Different syntax than PHP).
2. It's a language therefore it has a complier, the compiler slows down the scripts.

PHP is a templating engine itself. If you want a simple templating class(like me) then use www.phpsavant.com v2 (for now until v3 has a documentation).

It is 100% faster and easier than Smarty.
Haris is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:54 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design