Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 8377d4bb25a3992aad680df2952f4b71 > files > 182

php-smarty-doc-2.6.26-1mdv2010.0.noarch.rpm

<HTML
><HEAD
><TITLE
>What is Smarty?</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Smarty Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Getting Started"
HREF="getting.started.html"><LINK
REL="PREVIOUS"
TITLE="Getting Started"
HREF="getting.started.html"><LINK
REL="NEXT"
TITLE="Installation"
HREF="installation.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="chapter"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Smarty Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="getting.started.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="installation.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="chapter"
><H1
><A
NAME="what.is.smarty"
></A
>Chapter 1. What is Smarty?</H1
><P
>&#13;   Smarty is a template engine for PHP. More specifically, it facilitates a
   manageable way to separate application logic and content from its
   presentation. This is best described in a situation where the application
   programmer and the template designer play different roles, or in most
   cases are not the same person.
  </P
><P
>&#13;   For example, let's say you are creating a web page that is displaying a
   newspaper article. The article headline, tagline, author and body are
   content elements, they contain no information about how they will be
   presented. They are passed into Smarty by the application, then the
   template designer edits the templates and uses a combination of
   HTML tags and template tags to format the presentation of these elements
   (HTML tables, background colors, font sizes, style sheets, etc.) One day
   the programmer needs to change the way the article content is retrieved (a
   change in application logic.) This change does not affect the template
   designer, the content will still arrive in the template exactly the same.
   Likewise, if the template designer wants to completely redesign the
   templates, this requires no changes to the application logic. Therefore,
   the programmer can make changes to the application logic without the need
   to restructure templates, and the template designer can make changes to
   templates without breaking application logic.
  </P
><P
>&#13;   One design goal of Smarty is the separation of business logic and
   presentation logic. This means templates can certainly contain logic under
   the condition that it is for presentation only. Things such as including
   other templates, altering table row colors, upper-casing a variable,
   looping over an array of data and displaying it, etc. are all examples of
   presentation logic. This does not mean that Smarty forces a separation of
   business and presentation logic. Smarty has no knowledge of which is which,
   so placing business logic in the template is your own doing. Also, if you
   desire <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>no</I
></SPAN
> logic in your templates you certainly can
   do so by boiling the content down to text and variables only.
  </P
><P
>&#13;   One of the unique aspects about Smarty is the template compiling. This
   means Smarty reads the template files and creates PHP scripts from them.
   Once they are created, they are executed from then on. Therefore there is
   no costly template file parsing for each request, and each template can
   take full advantage of PHP compiler cache solutions such as Zend
   Accelerator (<A
HREF="http://www.zend.com/"
TARGET="_top"
>http://www.zend.com/</A
>) or PHP Accelerator
   (<A
HREF="http://www.php-accelerator.co.uk"
TARGET="_top"
>http://www.php-accelerator.co.uk</A
>).
  </P
><P
>&#13;   Some of Smarty's features:
  </P
><P
></P
><UL
><LI
><P
>&#13;     It is extremely fast.
    </P
></LI
><LI
><P
>&#13;     It is efficient since the PHP parser does the dirty work.
    </P
></LI
><LI
><P
>&#13;     No template parsing overhead, only compiles once.
    </P
></LI
><LI
><P
>&#13;     It is smart about recompiling only the template files that have changed.
    </P
></LI
><LI
><P
>&#13;     You can make <A
HREF="language.custom.functions.html"
>custom functions</A
>
     and custom <A
HREF="language.modifiers.html"
>variable modifiers</A
>, so the
     template language is extremely extensible.
    </P
></LI
><LI
><P
>&#13;     Configurable template
     <A
HREF="variable.left.delimiter.html"
>delimiter tag</A
>
      syntax, so you can use
     {}, {{}}, &#60;!--{}--&#62;, etc.
    </P
></LI
><LI
><P
>&#13;     The <A
HREF="language.function.if.html"
>if/elseif/else/endif</A
>
     constructs are passed to the
     PHP parser, so the {if ...} expression syntax can be as simple or as
     complex as you like.
    </P
></LI
><LI
><P
>&#13;     Unlimited nesting of
     <A
HREF="language.function.section.html"
>sections</A
>,
     ifs, etc. allowed.
    </P
></LI
><LI
><P
>&#13;     It is possible to
     <A
HREF="language.function.php.html"
>embed PHP code</A
>
     right in your template files, although
     this may not be needed (nor recommended) since the engine is so
     customizable.
    </P
></LI
><LI
><P
>&#13;     Built-in <A
HREF="caching.html"
>caching</A
> support
    </P
></LI
><LI
><P
>&#13;     Arbitrary <A
HREF="template.resources.html"
>template</A
> sources
    </P
></LI
><LI
><P
>&#13;     Custom <A
HREF="section.template.cache.handler.func.html"
>cache handling</A
>
     functions
    </P
></LI
><LI
><P
>&#13;     <A
HREF="plugins.html"
>Plugin</A
> architecture
    </P
></LI
></UL
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="getting.started.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="installation.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Getting Started</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="getting.started.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Installation</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>