Gossamer Forum
Home : General : Internet Technologies :

Smarty Templates

Quote Reply
Smarty Templates
Has anyone had any experience with Smarty Template Engine?

http://smarty.php.net/

Is it the PHP equiverlant of the GT template parser?

Any good or bad feedback?

Thanks

Simon.
Quote Reply
Re: [jai] Smarty Templates In reply to
Try writing your own. I have one, and it works something like;

Code:
// send to rountine, ready to pass back HTML...
$_html = create_includes("Welcome!");

// make the content for the page...
$_content = get_template_("include_front.html");

//. do some replacing, and then print it...
$_html = ereg_replace(":::content:::", "$_content" , $_html);
$_html = ereg_replace(":::days:::", "$_days_left", $_html);
$_html = ereg_replace(":::username:::", "$COOKIE_USER",$_html);
$_html = ereg_replace(":::guests:::", "$guests", $_html);
$_html = ereg_replace(":::address:::", "$address", $_html);
$_html = ereg_replace(":::todo:::", "$todo", $_html);
$_html = ereg_replace(":::gifts:::", "$gifts", $_html);
$_html = ereg_replace(":::gifts_assigned:::","$gifts_assigned",$_html);
$_html = ereg_replace(":::tables_used:::", "$tables_used", $_html);
$_html = ereg_replace(":::guests_used:::", "$guests_used", $_html);
$_html = ereg_replace(":::estimate:::", "$_budget[0]", $_html);
$_html = ereg_replace(":::actual:::", "$_budget[1]", $_html);

echo $_html;

Basically, the first routine will create the main page.. based on a set template. The second command, will then grab the content page for the specified process running, and the preg_replace() commands will just replace the tags. They are only basic ::tags::: (nothing as advanced as GT's template parser) .. but if you don't need anything fancy.. then try something like this.

A lot of these 3rd party 'modules' are pretty slow, as they do far too much for what you need.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Smarty Templates In reply to
I'm only interested in Smarty because the aMember passworrd manager uses it. I was just wondering if it's any good?

Thanks.

Simon.

PS. The PHP looks interesting, I'll have to look into it more.
Quote Reply
Re: [jai] Smarty Templates In reply to
I've tried to keep away from these kind of things. Smarty Templates/PHPTemplate, and other (which I can't remember the name of....lol) ... They all drive me mad. Half of them don't work as expected. If you are new to PHP, then feel free to have a go with it. It'll either work for you, or not (for me, it didn't, which is why I wrote my own codes).

I would recommend writing your own kinda of routines for PHP ... ie error routines, SQL error catching, template parsing, etc. Its all a case of just playing with it, and making it suite your needs.

Again, its totally up to you how/what you do.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [jai] Smarty Templates In reply to
Smarty is decent enough. Out of the different template engines in php, it's the only one ive found that is decent.

Good enough in fact that myself and another developer made a push for moving our site (which would be considereda BIG enterprise site) to make smarty standard.

While the whole site is not migrated to it, we forced all new development to be done using smarty, as well as changing over any old applications that we needed to do major work in.

It's helped a lot, and our customer experience team (who are responsible for look and feel aspects) are very happy with it as well since they don't have to bother with looking inside actualy code, or giving the programmers the design to shoe-horn in

--mark

Last edited by:

Mark Badolato: Aug 27, 2003, 8:10 AM