stargeek
PHP news website logo.
home    PHP scripts    articles    seo tools    links    search    contact    shop    realtors


Smarty for Beginners







Smarty for Beginners

Smarty for Beginners 12/28/2003 11:50 PM

Join Hermawan as he shows you the basic of the Smarty templating system.




This is a GrokNews Entry: (what is grok?)





Similar Items

Smarty for Beginners

Grok Headline matches for Smarty for Beginners

PHP CLI For Beginners


PHP CLI For Beginners 06/26/2002 08:05 PM
Many of you probably have already heard or read about the ability that PHP has to run as a command line interpreter (CLI). Using PHP as a CLI gives a programmer powers similar to Perl or even many of the shells found on Unix/Linux systems...

Ume for Beginners


Ume for Beginners 08/01/2004 10:02 PM
The ume, or Japanese Apricot, is an interesting little fruit, and it has the added cachet of being Japanese, so obviously there are hordes of ravening fanboys out there just waiting to read a detailed description of this mouth-puckering delicacy.

NEW Beginners Guides


NEW Beginners Guides 04/17/2005 11:10 AM

TrackBack for Beginners


TrackBack for Beginners 10/29/2003 12:10 AM
We've created a guide called A Beginner's Guide to TrackBack, since some people were having trouble understanding exactly what the...

Beginners FPS game in C++


Beginners FPS game in C++ 08/31/2004 01:08 PM
To all team members

OAI for Beginners Online Tutorial


OAI for Beginners Online Tutorial 11/03/2003 05:29 AM
OAI for Beginners - the Open Archives Forum Online Tutorial
http://www.oaforum.org/tutoria l/

This tutorial is an introduction to the Open Archives Initiative Protocol for Metadata Harvesting (OAI-PMH).

Working through this tutorial you will:

* gain an overview of the history behind the OAI-PMH and an overview of its key features;
* achieve a deeper technical insight into how the protocol works;
* learn something about some of the main implementation issues;
* find some useful starting points and hints that will help you as an implementer.

The Overview, History and Development of OAI-PMH, and Glossary may be used on their own to gain information about OAI and OAI-PMH without going into technical implementation details.

Beginners Computer Reference


Beginners Computer Reference 03/19/2003 10:43 PM
From the feedback I get from time to time. I know some of you are beginner Geeks and are looking...

Standards Resources for Beginners


Standards Resources for Beginners 08/27/2004 01:44 PM

Questions about beginners resources have been coming fast and furious lately; let's build a list!


Introducing Maya 6: 3D for Beginners


Introducing Maya 6: 3D for Beginners 12/17/2004 06:34 PM
Today, author Dariush Derakhshani shows you how to create a 3D representation of our solar system and the mechanics of animating orbits. You'll learn about creating simple objects, setting simple keyframes, and stacking your animation to get planets and moons to orbit each other and the sun. By Sybex. 1101

VoIP 101: Voice over IP for Beginners


VoIP 101: Voice over IP for Beginners 04/01/2005 11:21 AM

Outsourcing 101 – Offshoring for
Beginners


Outsourcing 101 – Offshoring for
Beginners
06/18/2004 03:10 AM
The Outsourcing Times has announced the launch of a special report, "Outsourcing 101 – Offshoring for Beginners". The report discusses the history, economics and political implications behind offshore outsourcing. [PRWEB Jun 18, 2004]

Robot Building for Beginners


Robot Building for Beginners 01/04/2005 05:50 PM

Best 35mm SLR Camera for Beginners?


Best 35mm SLR Camera for Beginners? 12/09/2003 07:25 PM

Beginners Guides: Burning CDs and DVDs


Beginners Guides: Burning CDs and DVDs 12/18/2003 04:37 AM
For those of you that are beginners or have a family member that is getting a computer and you do...

Infosecwriters.com : Buffer Overflow for
Beginners


Infosecwriters.com : Buffer Overflow for
Beginners
01/11/2004 09:03 AM
http://www.infosecwriters.com/texts.php?op=display&id=134 A starting point for this tutorial requires the readers to have a simple understanding of the C programming language, the way the stack and memory is organised, and asm knowledge is helpfull though not essential. (I always wanted to say that heh) When I refer to Buffer overflows throughout this article, I am refering to stack based overflows, there is a difference between stack based overflows, and heap based, though as...

the perl beginners mailing list


the perl beginners mailing list 01/23/2004 06:31 PM
what an uncharacteristically well-done form of outreach from techies

HTML - An Interactive Tutorial for
Beginners


HTML - An Interactive Tutorial for
Beginners
02/07/2005 01:55 AM
HTML - An Interactive Tutorial for Beginners
http://www.davesite.co m/webstation/html/

HTML stands for the HyperText Markup Language. HTML code is the major language of the Internet's World Wide Web. Web sites and web pages are written in HTML code. With HTML code and the world wide web, you have the ability to bring together text, pictures, sounds, and links... all in one place! HTML code files are plain text files, so they can be composed and edited on any type of computer... Windows, Mac, UNIX, whatever. his tutorial is for anyone who is serious about learning HTML code. Perhaps you want your own web page, or an entire web site. Perhaps you're setting up a web site for your business or organization. You've come to the right place. You do not need any prior experience in making web pages to take this course (although I will assume you know how to do some basic things with your computer, like use a word processor). This tutorial is a "hands on" tutorial... you get to test your new HTML skills immediately after you learn the code, chapter by chapter ... all within your web browser! There is no need to go fiddle with other applications while you are learning HTML code with this tutorial. This has been added to Tutorial Resources Subject Tracer™ Information Blog.

New Mailing List for Perl Beginners


New Mailing List for Perl Beginners 04/18/2004 03:18 AM
offerk writes "Over the last few years the Israeli Perl Mongers mailing list has grown significantly in both number of subjects and number of posts, to the point where there are now hundreds of posts per month. Since the large number of topics and the ...

XHTML Web Design for Beginners - Part 1


XHTML Web Design for Beginners - Part 1 01/27/2003 10:04 PM
WebmasterBase Jan 27 2003 8:43PM ET

Zend: Absolute Beginners Section Created


Zend: Absolute Beginners Section Created 08/02/2004 08:31 AM
Zend has developed a section just for those out there new to the PHP language and community. In the Absolute Beginners section, they have articles on such topics as operators, form processing, using loops all the way up to creating functions and scoping variables.

Beginners Guides: Burning CDs and DVDs
Part 2


Beginners Guides: Burning CDs and DVDs
Part 2
12/15/2003 09:19 AM

Really Basic REALbasic offers new
content for beginners


Really Basic REALbasic offers new
content for beginners
12/29/2003 04:16 PM
Mac software developer To the Point Software announced on Monday that it has updated its free Really Basic REALbasic Web tutorial with new example projects and informational topics.

Beginners Guides: Cloning WindowsXP @
PCstats


Beginners Guides: Cloning WindowsXP @
PCstats
04/15/2004 06:18 AM

Good Online FPS Games/Servers For
Beginners?


Good Online FPS Games/Servers For
Beginners?
02/10/2004 02:52 AM
Slashdot Feb 9 2004 10:14PM GMT

Beginners Guides: 99 Performance Tips
for WindowsXP - PCStats.com


Beginners Guides: 99 Performance Tips
for WindowsXP - PCStats.com
05/31/2004 10:07 PM
Beginners Guides: 99 Performance Tips for WindowsXP - PCStats.com

pcstats.com/articleview.cfm?articleID=1590
track this site | 4 links


Say it Ain't So, Smarty


Say it Ain't So, Smarty 06/07/2004 12:09 PM
Belmont Stakes turned out impressive results, despite the outcome.

Smarty has a Wiki


Smarty has a Wiki 07/15/2002 01:36 PM
This Wiki is provided to allow the Smarty community (in particular members of the smarty-general mailing list) somewhere to help contribute documentation to the Smarty project. This can include tips, howtos, addons, or answers to frequently asked questions. Useful content added to the Wiki can then be rolled in to the official Smarty documentation later on.

There has been some criticism that the Smarty documentation is more useful to experienced developers than to template designers and end users. This Wiki is here to help change that.

"tri" Smarty is a popular PHP template engine that allows you to separate your code and data. A Wiki is an amazing editing and HTML generation system.

"zeldman.54"

Mr. Smarty Pants


Mr. Smarty Pants 02/18/2004 12:04 PM
It's common for pregnant women to dream they've given birth to an animal. According to a report by the New York Post, Winston Churchill's parrot is still alive. Charlie, a 104-year-old blue and gold female macaw, lives in southeast England and likes to curse Hitler. In the first century, Pliny the Elder claimed that mustard would improve lazy housewives. All of these "facts" and more can be found in the Mr. Smarty Pants Archive.

Smarty pants!


Smarty pants! 05/14/2004 01:26 PM
Where do you live, among a bastion of geeks, or sea of academia-phobes? US Census released the smartest cities, states, and counties with Seattle and Raleigh topping the cities. Also for those who are politically curious, of the top 15 states with Bachelor degrees 11 went to Gore, while 13 of the bottom 15 went to Bush.

Smarty as a "Sub-Language"


Smarty as a "Sub-Language" 03/22/2005 04:31 PM

I've been spending some time working with Smarty lately. This is ostensibly a "templating language" for PHP. But I think it goes beyond that. I assert that Smarty has become a sub-language all by itself.

(Update: I thought of a much better name for this: "sand-boxed PHP." That's what Smarty is — a sandbox into which you can release as much or as little PHP functionality as you want.)

First of all, for the record, Smarty is astonishingly well-done. Joe tried to get me to use it for about a year, and I resisted because I've hated most templating languages I had worked with. (Lately, Joe is bugging me to try Rails, so I'm sure I'll do that about a year from now. I'm usually about a year behind Joe.)

I've spent just two weeks or so with Smarty, and I'll never, ever go back. It's one of those rare things that was written the way you would have written it if you had all the time in the world and were a lot smarter than you actually are.

What I love about Smarty is the extensibility. You can take any logic and wrap it up into a function or a modifier and expose it to Smarty, so it can be used in templates. Anything — if you can write it in PHP, you can reduce and simplify it down to a tag in Smarty.

This means that you could essentially write a new programming language in Smarty — a language that runs within PHP. Smarty already includes v ariables, flow control, several built-in modifier s and functions, and an i nclude system that's essentially a way to create user-defined functions.

Once you start wrapping up some advanced functionality into Smarty tags, you could create an entire language, teach your template developers how to use it, and they'd never know they were actually using PHP unless you told them. They'd essentially be "programming" in a sub-language that runs inside of PHP. (If they ever ask you what language you're teaching them, just string three letters together — "RTI" or "DBN" or something. They'll buy it.)

Let's consider ColdFusion, which is the language we would come the closest to if we pushed Smarty as far as it could go. This code in ColdFusion pulls a recordset, loops through it, and prints everything out.

<cfquery name="news" datasource="news">
  SELECT * FROM news
</cfquery>

<cfoutput query="news">
  #news.title#
  <br>
</cfoutput>

Now, here's the same thing in a Smarty template:

{query name="news"}
  SELECT * FROM news
{/query}

{foreach from=$news item=article}
  {$article.title}
  <br>
{/foreach}

All this took was a custom, 10-line blo ck function (written like this) that allows the template author to provide the SQL statement to be executed and returns a two-dimensional array. (Before you send the hate mail, yes I know this is wrong. I know this is a perversion of everything Smarty is supposed to do. I'm just trying to make a point here.)

So Smarty can be made to function very much like ColdFusion. It's not hard to take this further. Assign the $_GET and $_POST variables, and you can provide some dynamic functionality. This assignment:

$smarty->assign('_get', $_GET);

Will let you do this in the above template:

{query name="news"}
  SELECT * FROM news WHERE title LIKE '%{$_get.q}%'
{/query}

Now template authors can create a mini-app that searches a database table. It's not hard to see how you could make scripts to let them update tables as well.

But, you may say, Smarty has to be invoked from a PHP page, so the templates cannot be URL-addressable. True, but you can automate this. You can just route all incoming requests to the same PHP page, like this:

AliasMatch ^.*$ /template_loader.php

Then, in that file, do something like this:

$smarty->display($_SERVER['REQUEST_URI']);

This will load whatever template was called in the (fake) URL. So now template authors can start stringing templates together. Before you know it, they've gone and built a simple app. By themselves. Without you. In a language that you gave them. That runs inside of — and is essentially controlled by — PHP.

Your programming environment has now been split into a "main" language and a "sub" language, both of which you have control over. You can give your template authors as much or as little functionality as you want (you "wrote" the language, remember). They can solve as many problems as they can with what you've given them. For other problems, you can tackle them in "real" PHP and just provide the result, or you can encapsulate the algorithm and expose it to Smarty via a function or modifer.

Is this a good thing? I can't decide. But it sure is interesting, ain't it?


If you've got experience with PHP and
Smarty under ...


If you've got experience with PHP and
Smarty under ...
12/31/2003 07:23 PM


If you've got experience with PHP and Smarty under OS X, I' m having a problem with if()s in the compiled templates. Any suggestions?


Codewalkers: Getting Into Smarty


Codewalkers: Getting Into Smarty 12/29/2003 10:59 AM
Once most coders get into the more advances realm of PHP development, they quickly realize that they're going to need some kind of simple system to template the pages of their site. Enter the Smarty template system. And, to get you started with this popular templating engine, Codewalkers.com has a new tutorial to help.

Smarty Quotes


Smarty Quotes 03/11/2003 09:43 AM
Nelson Minar rages against the dying of design, in his summary of a discussion with Cory Doctorow around using smart quotes and other typographic niceties in weblogs.
I want to use fancy Unicode characters like U+201C and U+201D ("smart quotes") in my blog. Cory hates that idea because non-ASCII characters behave badly when you paste them into your email or text editor and that they don't work well in RSS.

The underlying problem is an impedence mismatch between new Unicode oriented tech like the Web and XML and old ASCII oriented tech like email and text editors. Browsers and RSS readers should mediate between the two but software often gets it wrong.
This discussion continues a conversation on the SmartyPants plug-in I hacked together for Blosxom.

While compromising design for the sake of compensation for badly integrated technologies and encodings is not on in my book, some allowance must be made for the simple copy-n-paste. To that end, I've added a plainlink (txt) to my template alongside the permalink. This link leads to an utterly plain text (non-smarty) version of the story at hand.

Using Smarty: RSS For Every Page


Using Smarty: RSS For Every Page 10/29/2003 01:14 AM
Since all the entry data is stored in a PHP file anyway, and it is parsed out into one form already (XHTML) I figured “What the hell? Why not?” Add ”?rss” to any page on this site for the corresponding...

Smarty-Light 2.2.1


Smarty-Light 2.2.1 08/04/2004 11:15 AM
A fast template engine for PHP.

Smarty-Light


Smarty-Light 07/14/2004 08:42 PM
One Year Anniversary, Version 2.1.1

Somewhere Smarty Jones Is Crying


Somewhere Smarty Jones Is Crying 06/13/2004 01:30 PM
Man Beats Horse, wins 25,000 pounds. For the first time, two legs triumphed over four in the annual Man Versus Horse Marathon in Wales.

SmartBee - the Smarty Framework


SmartBee - the Smarty Framework 06/16/2004 06:57 AM
first pre alpha version relased

Smarty PHP template engine 2.6.3


Smarty PHP template engine 2.6.3 06/17/2004 12:15 AM
The PHP compiling template engine.
Grok Description matches for Smarty for Beginners
GrokA matches for Smarty for Beginners

Smarty for Beginners

The following phrases have been identified by the grok system as matching this entry:

















Also check out:


Grok

Ipod Porn on the
Rise

Brief Abstract of
Wikipedia's
Mesothelioma Cancer
page

Get first aid
instructions in your
cell phone

IE is crap
JSPWiki gains
podcasting support

Handset Shortage
Plagues South
Korea's 3G Cell
Phone Service

COMDEX 2003 - South
Korean Technologies
(Pics)

Registry Mechanic
Version 2.01 for
Windows

Volunteer
Programmers Wanted

Microsoft, Reliance
in gaming pact

Big Intrusions, Tiny
Pictures and
Patented Problems

ActiveWin.com:
Microsoft DirectX
9.0b Frequently
Asked Questions Page
(FAQ) - Updated

Computer glitch hits
NZ exchange

Marconi and C&W
executives pocket
millions

Four Dead in Mid-Air
Crash Between 2
Craft

Man, 4 Kids Die in
Utah Motor Home
Crash

Iran Says Quake
Death Toll Could
Reach 30,000

Five More Bodies
Found in Calif.
Mudslide

Kaz wins AU$20
million Defence
contract

The RIAA will fight
on

S. Korea to set up
govt investment arm

Hub & Seoul of
North-East Asia

IP law to stay hot
in Aust in 2004

'Robot Tarzan' helps
forest work

MacRumors in 2003
Best products of
2003

Satellite Radio
Subscriptions Rising

Looking pretty good
so far

Technology moves
faster than
regulators

Adobe Reader v6.0.1
TIFNY v4.502
Plans 5.1
ZINC interpreter
1.03

Java Remote Method
Invocation Language
2.0.5

nget 0.26
jsSimon 1.1
Rob Enderle: Putting
The 'Anal' In
'Analyst'

Real verdict in
China for virtual
loss

Terrorist email
spreads trojan virus
in Malaysia

Email terrorism
Virtual justice
Holiday Rush Demands
High-Pressure
Hosting

Web Hosting Industry
Appointments in 2003

New Web Hosting
Industry Products
and Services

The Discount
Dedicated Hosting
Market in 2003

theWHIR's Web
Hosting Industry CEO
Roundtable

'03 lingo, from
Bennifer to zhuzhing

Wall Street Watch:
Search for IPO
investors may return
fewer hits

2003! India can look
back with glee

Macon Area Online
Turns Three

Google chief coy on
IPO rumors

Mapping services are
proving a bit too
convenient

Mooter eyes stock
exchange float

Bay Area IPO market
showing new signs of
life Investors think
...

Newsletter aims to
serve baby boomers

what is grok?