Go Back   SitePoint Forums > Forum Index > Community Center > Community Crier
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Closed Thread
 
Thread Tools Display Modes
Old Jul 23, 2002, 20:09   #1
mjames
Sports Publisher
 
mjames's Avatar
 
Join Date: Jan 2000
Location: Charlotte, NC
Posts: 6,022
SitePoint Community Crier #29

The SitePoint COMMUNITY CRIER #29 Copyright (c) 2002
July 24, 2002 PLEASE FORWARD
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
An email newsletter for the SitePoint Community, written and
edited by Nicky Danino and Aaron Brazell.
(crier.removethis@.removethissitepoint.com).

Note: This newsletter is supported solely by advertisers like the
one below. We stand 100% behind every ad that we run. If you ever
have a problem with a company that advertises here please contact
us and we will try to get it resolved.

SPONSOR'S MESSAGE - - - - - - - - - - - - - - - - - - - - - - - -

Kev's PHP/MySQL Book is a Great Business Tool

Are you ready to succeed in 2002? With Kevin Yank's acclaimed new
book, "Build Your Own Database Driven Website Using PHP & MySQL",
you'll be able to:

CHARGE MORE for your time

FREE YOURSELF from time consuming site updates

SPEED UP site redesigns and overhauls

Read Sample Chapters Now: http://sitepoint.com/books/?bookid=BookInfo

IN THIS ISSUE - - - - - - - - - - - - - - - - - - - - - - - - - -
- ADMIN'S DESK
- COMMUNITY ARTICLE - Introducing Smarty
- SIZZLING HOT TOPICS
- MEMBER SPOTLIGHT
- TIPS AND TRICKS
- SOUND OFF
- ReferWare


ADMIN'S DESK - - - - - - - - - - - - - - - - - - - - - - - - - -

Greeting and Salutations.

We've been busy, busy, busy at SitePoint -- as usual! In fact,
there are so many things going on that I think I'm going to need
to clone myself so that I can even *read* all the things that are
happening across the forums.

Not only is our resident editor Georgina planning some GREAT
interviews, but some of our keen volunteers have put a project
together and are looking for helpers to build Websites for
charity -- more to follow soon!

We have also launched a SitePoint Awards program, which I'm
really looking forward to. Who will you vote for as ASPer of the
year? What about Staff member of the year? (ahem, of course
you'll all vote for me, or I'll get in a strop and not smile for
a week). I'm still in contention with the rest of the staff on
these awards, though I think that we're missing several
categories, namely: chocolate eater of the year, and of course,
member who has mentioned the word 'chocolate' in the most
threads.

In this issue of the Crier we have an article about a
PHP-compiling template engine. I had no idea what it was all
about, but reading the article gave me a great insight into some
of the handy tools that exist to make the job of maintaining our
Websites a lot less stressful. We also have an interview with our
beloved Mentor Aes, and some useful tips and tricks from our
members.

Have fun, don't eat 'til you explode!

So Be It!

SPONSOR'S MESSAGE - - - - - - - - - - - - - - - - - - - - - - - -

MCHost - Experts in Private Label Reseller Plans and Managed Servers

MCHost gives you the freedom to run your hosting business your way
allows you to host Unlimited Domains under one large plan!

Create, edit and remove hosting accounts in real-time, view and
limit bandwidth usage, password modification, full control over your
clients accounts and much more! No more buying each of your account's
separately - now you can host all your customers domains under one
account and have full control!

We offer you an your customers 24/7 customer care for any questions
and an active community to communicate with other clients. Over 1000
large hosting companies around the world trust in MCHost - the leader
in private label reseller plans.

Learn more right now at: http://www.mchost.com/home/

COMMUNITY ARTICLE - - - - - - - - - - - - - - - - - - - - - - - -

Introducing Smarty - the PHP-compiling template engine

Smarty (http://smarty.php.net) is a PHP template engine written
by Monte Ohrt and Andrei Zmievski. Yet another template engine
you say? The authors (and I too) would disagree. Smarty is
different from the rest of the pack.

What differentiates Smarty from other template engines like
FastTemplate and patTemplate is that Smarty compiles your
templates into PHP scripts, eliminating the overhead incurred in
parsing the templates every time they're accessed. This makes
Smarty very scalable for large applications and high-traffic
Websites ...and if that didn't make any sense to you, just take
it that Smarty is very fast and would work well in stressful and
high-traffic conditions!

The Smarty template engine has several other outstanding features
besides template compilation, and we'll discuss these a little
later. But first, let's de-mystify template compilation...


- Template Compilation Explained

What does 'compilation of templates' mean, anyway? What do Web
pages have to do with compiling? Isn't compiling something C++
and Java programmers do? Yes - but this is a different sort of
compilation.

Smarty parses your templates and creates PHP scripts from them
(instead of binaries, as in general programming). Then, when your
Web page is viewed, Smarty reads from these PHP scripts instead
of pulling the templates themselves, which saves the work of
having to parse your templates again.

Smarty is smart about when to compile, too: it only re-compiles
your templates when you make changes to them, so you don't have
to worry about manually compiling the templates (this is similar
to JSP, if you're aware of how it works).

The good thing about this is that you don't even have to know the
PHP scripts are there, nor how compiling works. It's all hidden
from view, so if you employ template designers to work on your
templates, they (or you, if you design your own templates) don't
have to know that Smarty is a 'compiling template engine'.


- Caching

Smarty also features built-in caching of your template outputs.
Smarty caches the output of the template contents, saving the
overhead expense involved in retrieving your data from a data
source. This data source would usually be external and slow, and
is often the bottleneck in your application, like a remote
database. Smarty caches the output of your template with this
data from your data source, and saves you from having to connect
to the database every time your Web page is accessed.

If you have a slow-responding database server or are making
multiple queries to your database, this caching feature would
greatly improve the performance and responsiveness of your Web
pages.

Of course, there are cases when you don't actually want your
template output to be cached, for instance, a stock ticker or
situation where you constantly make changes to your database,
which need to be immediately reflected on your Web pages. No
problem! Smarty is again smart enough to allow you to specify
what should or should not be cached.

In fact, you can have cached and un-cached portions on the same
template page, as Smarty allows you to specify exactly what you
don't want cached (like that stock ticker at the bottom of the
page) and what you do want cached (such as your navigation bar,
which is seldom changed). You can also set the cache expiry time
so that your template output is cached only for a specific length
of time. You can thus achieve the middle-ground between having
up-to-date dynamic content and quick-to-load Web pages.

One point to note (and which the authors of Smarty are quick to
point out) is that this caching functionality is totally
different from that of Zend Cache, PHP Accelerator and the like.
Caching tools like PHP Accelerator cache the complied bytecode of
your PHP scripts, whereas Smarty caches the output of your
templates.

As such, Smarty can work hand in hand with Zend Cache, where Zend
Cache would cache the PHP scripts that Smarty creates from your
templates. This makes for excellent performance, as evidenced by
benchmarks (http://www.phpinsider.com/benchmarks_phemplate/). To
quote the authors: "Smarty's performance _really_ excels in
combination with a PHP accelerator."


- Variable Modifiers

Smarty also provides variable modifiers, which, as the name
implies, allow you to modify the contents of a variable. You can
do things like uppercase a string (e.g. {$title|upper} which
would convert your $title into all uppercase characters),
truncate a string (e.g. {$content|truncate:30} which would allow
you to display the first 30 characters of $content and follow
that with '...', particularly useful for displaying email or
forum topic previews) or even use regular expressions to search
and replace a string (e.g. {$article|regex_replace:"/bad
word/":"***"} which would replace all occurrences of 'bad word'
in $article with '***').

Variable modifiers give your template designers the ability to
modify your template variables without being confused by those
funny characters we programmers so like to use.

This sanitized method of 'programming' gives your template
designers greater control over the formatting of your template
variable, though they would need to know the variable modifiers
available to them. It is still, without doubt, a useful feature,
as the syntax is kept simple and is accessible to even
non-programmers.


- Template Functions

Smarty provides built-in and custom functions for use in your
templates. These functions are like the API of Smarty templates,
except that custom functions can be modified but not built-in
functions. Functions allow you to do things like program
conditional output (using if statements), perform iteration with
dynamic loops (using foreach or section), load config files,
cycle though a set of values (useful for alternating table row
colors), keep a counter (useful for numbering list data), and
much more. Particularly of use to those of us generating Web
pages with content from databases are the looping functions
(section and foreach), which you can use to loop over and display
a result set.


- Filters

Smarty allows you to specify ('register' or 'load' actually)
filters through which you can run your templates before or after
they are compiled. Prefilters are functions that your templates
are run through before they're compiled; postfilters after; and
output filters, upon the template output as it is requested. 'Why
filters?' you say.

Prefilters allow you to do things like removing unwanted comments
(such as those created by Dreamweaver) and ensuring content in
the templates you don't want does not go through to the compiler.

Postfilters let you add additional information to your templates,
such as the template creation date (as a comment) after they're
compiled. Output filters give you the ability to modify your
template output, allowing you to do things like obfuscating email
addresses on your Web page to protect against spambots (using a
preg_replace()).


- Config Files

Config files are configuration files where you can store global
template variables. This allows you to store variables that
should affect every template (i.e. global variables) in a central
location.

A good example of such a variable would be the color scheme for
your templates. Your template designers only have to change the
values in the config file should a color scheme revamp be
required. This saves them suffering through the painful
alternative of going through every individual template to change
the colors.

Config files also allow for sections, which are not unlike those
in .ini files. The section names are enclosed in brackets (e.g.
[welcome_page]) and are only loaded upon request. Anything that's
not in a section is globally available (upon a call to the
config_load function).


- Plug-ins

The Smarty plug-in architecture was introduced in version 2.0 and
allows you to customize Smarty to suit your purposes (however
grand or nefarious). The prefilters, postfilters and output
filters I discussed earlier are just some of the plug-in types
available to the customizer. Other plug-in types are the
modifier, block, compiler, resource and insert types.

With plug-ins, you can create your own template functions,
variable modifiers and filters. You can even change the data
source you want Smarty to read from (the default is from flat
files), using a resource plug-in. With a resource plug-in, you
can save your templates in a database, and retrieve them using
sockets (or any other method you use to access templates with
PHP. This means you can access just about any source).


- Conclusion

Smarty is a quality template engine and one you should definitely
consider, should you be on the lookout for a PHP version.

Combine Smarty's template compilation and PHP's inherent
efficiency in generating Web pages, and you've got yourself a
winner in the speed race. Smarty also offers extensive
functionality, including template functions and variable
modifiers, which can be extended using a well-designed plug-in
architecture.

All that speed and functionality doesn't come at the price of
usability: the learning curve is no steeper than that of other
template engines. Smarty is also supplemented with excellent
documentation that's available online and for download at the
Smarty Website (http://smarty.php.net).

Andrei Zmievski, one of the authors, works on the PHP development
team too, and he keeps Smarty's development closely tied to that
of PHP. So you can be confident that the latest changes to PHP
(like the recent register_globals issue in PHP 4.2.0) will be
supported by Smarty.

by Joel Cheah
aka Redemption

SPONSOR'S MESSAGE - - - - - - - - - - - - - - - - - - - - - - - -

* At last, a TextBox replacement for Content Management Systems *

If you're stuck in the old way of doing things, your next step would
be to teach everyone responsible for adding, editing and updating
content how to markup text using HTML or XML.

It's not a pretty or foolproof option. A single missing bracket,
a mistyped tag, and all of a sudden the formatting is all messed up.
Even worse is the amount of time required to create links, bold
words, or add color... unless you have Editize.

Editize is a rich-text Editor for Content Management Systems that
replaces the TextBox. With Editize, simple buttons and drop-down
menus replace incomprehensible and tedious markup code. Support
calls and human errors drop to zero. Time spent on adding, editing
and updating content is drastically slashed.

Get your FULLY FUNCTIONAL Trial Version here: http://tinyurl.com/pzi


SIZZLING HOT TOPICS - - - - - - - - - - - - - - - - - - - - - - -

Interview with.... The SitePoint Staff
http://www.sitepointforums.com/showt...threadid=68728

SitePoint Community Forums Awards!
http://www.sitepointforums.com/showt...threadid=69144

a cheap alternative to Zend Encoder for encoding PHP scripts
http://www.sitepointforums.com/showt...threadid=66726

A useful tool for building form elements?
http://www.sitepointforums.com/showt...threadid=68763

Is anyone making money advertising?
http://www.sitepointforums.com/showt...threadid=69034

Raising Venture Capital - What You Need to Know
http://www.sitepointforums.com/showt...threadid=69041

Suggestions for first time first meeting
http://www.sitepointforums.com/showt...threadid=65798

pro's + con's of databases
http://www.sitepointforums.com/showt...threadid=68599

Need help with fonts in Photoshop & making them look good
http://www.sitepointforums.com/showt...threadid=68928

PHP Tennis: Free-for-all
http://www.sitepointforums.com/showt...threadid=68545


MEMBER SPOTLIGHT - - - - - - - - - - - - - - - - - - - - - - - -

In this issue, the "Member Spotlight" falls squarely on the
shoulders of...Aes.
http://www.sitepointforums.com/membe...o&userid=11476

SP: How did you get started on the Internet?
Aes: When we got our first post-386 era computer equipped with
Windows '95 and America On-Line 3.0. Since then, the Internet’s
been a staple of my life!

SP: How did you come across SitePoint?
Aes: I became hooked on webmaster-resources.com when the euphoria
of building Websites and anyone being able to see them was still
new. Then came SitePoint.com transformation, and eventually I
wandered into the forums, and have been a member ever since.

SP: What are you up to at the moment?
Aes: Actually, Aaron (Sketch) is irritating me with his incoherent
PHP questions, but other than that I’m taking a break from my
Webmastering duties and having a little friendly chat.

SP: Do you have any interests (apart from SitePoint of course!)?
Aes: Friends most of all, and doing things with them. This is
followed closely by such activities as reading books, skating,
watching movies, and sleeping.

SP: What is your favorite movie of all time?
Aes: Has to be, without a doubt, 'O Brother, Where Art Thou?'

SP: ...and book(s)?
Aes: 'Ishmael' will always be a favorite, though I mostly enjoy
fantasy novels. 'The Wheel of Time' and 'Harry Potter' have to
take the top spots, with many more falling in just behind.

SP: ...same goes for song?
Aes: I don’t have any one favorite song. Basically, I like
everything but rap and country!

SP: If you could only visit one Website today (apart from
SitePoint of course), which would it be?
Aes: I do venture to SlashDot on occasion…


TIPS AND TRICKS - - - - - - - - - - - - - - - - - - - - - - - -

A sample of the advice you can find on our forums on a daily basis!

Another new critical security vulnerability found in PHP! Systems
Administrators Must Read!

A new security vulnerability has been discovered in PHP 4.2.
involving form handling. Evidently PHP 4.2 incorporated a new method
of form handling that can potentially give a malicious hacker root
access to your server! Needless to say, this is potentially the worst
security breach involved in the open source software so far.

Systems Administrators running PHP 4.2.0 or 4.2.1 are advised to
immediately upgrade to PHP 4.2.2. As usual, administrators running
any version of PHP prior to 4.2.x are advised to upgrade for other
security reasons.

For more information, visit http://www.php.net/release_4_2_2.php.

ADVERTISING INFORMATION - - - - - - - - - - - - - - - - - - - - -

I Caught You Reading An Ezine Ad!

Find out what thousands of savvy Internet marketers already know:
email newsletter Advertising Works! (You're reading one now,
aren't you?)

Find out how to get YOUR sponsorship ad in this newsletter.
Check out http://www.sitepoint.com/mediakit/ for details or
email us at mailto:adinfo.removethis@.removethissitepoint.com .

Ask about our special discount for multiple ad insertions!


REFERWARE - - - - - - - - - - - - - - - - - - - - - - - - - - - -

This newsletter is ReferWare. If you enjoy reading it and find
useful information in this newsletter, you are asked to help
spread the word about it. Forward a copy to your friends, tell
them about it, and/or place a link to it on your site.

You cannot:

1.) Post this newsletter in part or in whole on your site.
2.) Forward this newsletter issue after issue to people - just
send them a single issue and tell them to subscribe.

Sorry about those restrictions, our lawyer made me do it.


ADDRESSES - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Send suggestions and comments to:
mailto:crier.removethis@.removethissitepoint.com

SitePoint.com is hosted by Rackspace Managed Hosting:
http://www.rackspace.com

The SitePoint Community Crier is hosted by SparkList:
http://www.sparklist.com

The SitePoint Community Crier is (c) 2000-2002 SitePoint Pty.
Ltd. All Rights Reserved. No part of this Newsletter may be
reproduced in whole or in part without written permission. All
guest articles are copyright their respective owners and are
reproduced with permission.
mjames is offline  
Closed Thread

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 16:44.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved