SlideShare a Scribd company logo
Smarty 101
What? Why? How?


Ted Kulp - Shift Refresh, Inc.
What?
What?
Arguably the most widely used PHP templating
system
What?
Arguably the most widely used PHP templating
system

Created by Andrei Zmievski
What?
Arguably the most widely used PHP templating
system

Created by Andrei Zmievski

Tightly integrated into the CMSMS core
What?
Arguably the most widely used PHP templating
system

Created by Andrei Zmievski

Tightly integrated into the CMSMS core

Seamlessly used on all page, module and other
templates throughout the system
What?
Arguably the most widely used PHP templating
system

Created by Andrei Zmievski

Tightly integrated into the CMSMS core

Seamlessly used on all page, module and other
templates throughout the system

Released under the LGPL -- basically means it’s
pretty liberally licensed
Why?
Why?
Separates the display logic cleanly from the
controller logic
Why?
Separates the display logic cleanly from the
controller logic

Much safer by not allowing full range of PHP
functionality in a template
Why?
Separates the display logic cleanly from the
controller logic

Much safer by not allowing full range of PHP
functionality in a template

Allows for many tricks to make complicated
display easier
Why?
Separates the display logic cleanly from the
controller logic

Much safer by not allowing full range of PHP
functionality in a template

Allows for many tricks to make complicated
display easier

Get a lot of web-friendly functionality for free
Why?
Separates the display logic cleanly from the
controller logic

Much safer by not allowing full range of PHP
functionality in a template

Allows for many tricks to make complicated
display easier

Get a lot of web-friendly functionality for free

And mainly...
Why?
                             Ugly                               Not So Much
<html>                                                       <html>
<head>                                                       <head>
<title><?php echo $title; ?></title>                         <title>{$title}</title>
<?php cms_display_stylesheet() ?>                            {stylesheet}
<?php cms_display_metadata() ?>                              {metdata}
</head>                                                      </head>
<body>                                                       <body>
<div id=”body”>                                              <div id=”body”>
<?php cms_display_content(‘content_en’) ?>                   {content}
</div>                                                       </div>
<div id=”footer”>                                            <div id=”footer”>
<?php printf(‘%m %d %Y’, cms_page_data(‘date_modified’)) ?>   {modified_date|cms_date_format}
</div>                                                       </div>
</body>                                                      </body>
</html>                                                      </html>




                      It’s just plain easier to read
Absolute musts
Absolute musts


Literal tags
Absolute musts


Literal tags

Getting available variables
Absolute musts


Literal tags

Getting available variables

Modifiers
Literal Tags
Literal Tags

Escapes javascript
Literal Tags

Escapes javascript

Escapes CSS
Literal Tags

Escapes javascript

Escapes CSS

Really... escapes anything with { or } in it.
Smarty gets confused
Literal Tags

Escapes javascript

Escapes CSS

Really... escapes anything with { or } in it.
Smarty gets confused

So literal tags basically have Smarty ignore
everything between
Literal Tags
<script type="text/javascript">
/ Get all of the tabs and add an onmouseover
 /
/ event listener to each tab
 /
var tabs = getElementsByClass('tab',
    document.getElementById('featuresarea-tabs'),'li') ;
for(i=0; i<tabs.length; i++)
{
! var this_tab = ! document.getElementById(tabs[i].id);
! this_tab.onmouseover = function(){
! ! showtab(this.id);
! ! document.getElementById(this.id).className += " selected";
! };
}!
//]]>
</script>
Literal Tags
{literal}
<script type="text/javascript">
/ Get all of the tabs and add an onmouseover
 /
/ event listener to each tab
 /
var tabs = getElementsByClass('tab',
     document.getElementById('featuresarea-tabs'),'li') ;
for(i=0; i<tabs.length; i++)
{
! var this_tab = ! document.getElementById(tabs[i].id);
! this_tab.onmouseover = function(){
! ! showtab(this.id);
! ! document.getElementById(this.id).className += " selected";
! };
}!
//]]>
</script>
{/literal}
The Immortal Question



 How do I know what variables are available
 to me in my template?
Answer

{get_template_vars} !!!!!!!!

Gives you all the variables that are available
to that template. It’s a must have.

Know It

Use It

Love It
{get_template_vars}
On a regular page, outputs something like:
SCRIPT_NAME = /1.6.x/index.php
app_name = CMS
sitename = CMS Made Simple Site
lang =
encoding = utf-8
gCms = Object
cgsimple = Object
content_obj = Object
content_id = 69
page = get_template_vars
page_id = get_template_vars
page_name = get_template_vars
etc.
{get_template_vars}
On a regular page, outputs something like:
SCRIPT_NAME = /1.6.x/index.php
app_name = CMS
sitename = CMS Made Simple Site
lang =
encoding = utf-8
gCms = Object
cgsimple = Object
content_obj = Object
content_id = 69
page = get_template_vars
page_id = get_template_vars
page_name = get_template_vars
etc.                               Which means you can use:
                                          {$page_name}
                                  in this template and get the
                                           page’s name.
Modifiers
Modifiers
Take output and modifies it directly in
Smarty.
Modifiers
Take output and modifies it directly in
Smarty.

Allows multiple modifiers to be chained.
Modifiers
Take output and modifies it directly in
Smarty.

Allows multiple modifiers to be chained.

Format:   {$variable|modifier_function:extra:parameters}
Modifiers
Take output and modifies it directly in
Smarty.

Allows multiple modifiers to be chained.

Format:   {$variable|modifier_function:extra:parameters}


Chaining:   {$variable|modifier_function|another_one:with:params}
Modifiers
Take output and modifies it directly in
Smarty.

Allows multiple modifiers to be chained.

Format:   {$variable|modifier_function:extra:parameters}


Chaining:   {$variable|modifier_function|another_one:with:params}


Smarty comes with a lot of nice modifiers.
See chapters 5 and 6 for some examples.
Examples
Examples
{$title|upper} -- Convert the string to upper
case
Examples
{$title|upper} -- Convert the string to upper
case

{$title|truncate:40:’...’} -- Truncate the string at
40 characters and put an ellipsis on it
Examples
{$title|upper} -- Convert the string to upper
case

{$title|truncate:40:’...’} -- Truncate the string at
40 characters and put an ellipsis on it

{$smarty.now|date_format:”%Y/%m/%d”} -- Get
the current date and give it a nice formatting
Examples
{$title|upper} -- Convert the string to upper
case

{$title|truncate:40:’...’} -- Truncate the string at
40 characters and put an ellipsis on it

{$smarty.now|date_format:”%Y/%m/%d”} -- Get
the current date and give it a nice formatting

{$variable|var_dump} -- Any PHP function will
work
Tricks and Examples


{capture}

{cycle}

{mailto}
{capture}

Allows you capture output of smarty tags
and variables and used it elsewhere

Useful for testing if something has output
data

Allows you to get around issues where path
of execution isn’t correct
{capture} Example

Div should only show if there is content

  {capture name=outp}{content block=‘sideblock’|trim}{/capture}
  {if $smarty.capture.outp}
     <div id=”sideblock”>
       {$smarty.capture.outp}
     </div>
  {/if}
{cycle}


Used to alternate a set of values

Useful for alternating classes - ex.

  Alternating table rows

  Multiple columns
{cycle} Example

Split display of items into 2 columns

      {foreach from=$values item=‘the_item’}
        <div class=”{cycle values=”col1,col2”}”>
          {$the_item}
        </div>
      {/foreach}
{escape}


Encodes a variable in various formats -- ex.

  Encode an email address so that it’s not
  easily scraped by a spam bot

  Encode output to make sure it’s valid xhtml
{escape} example

Make a legible email address more difficult
         to read via the source.

       {$user.email|escape:”hexentity”}

 (Converts email@domain.com to %62%64, etc.)
Resources


http://smarty.net/manual/en (Please read
chapters 3 and 4 at a minimum!!!)

http://wiki.cmsmadesimple.org
Thank you!

More Related Content

What's hot (15)

PPT
Система рендеринга в Magento
Magecom Ukraine
 
KEY
PHP security audits
Damien Seguy
 
PDF
Introduzione JQuery
orestJump
 
PPTX
Maintainable JavaScript 2012
Nicholas Zakas
 
PDF
jQuery in 15 minutes
Simon Willison
 
PPT
Php Tutorial | Introduction Demo | Basics
Shubham Kumar Singh
 
KEY
前端概述
Ethan Zhang
 
KEY
jQuery Plugin Creation
benalman
 
PPTX
Phphacku iitd
Sorabh Jain
 
PPTX
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Balázs Tatár
 
KEY
jQuery Anti-Patterns for Performance & Compression
Paul Irish
 
PDF
jQuery Essentials
Marc Grabanski
 
PDF
Plugin jQuery, Design Patterns
Robert Casanova
 
PDF
Make your own wp cli command in 10min
Ivelina Dimova
 
PDF
Curso Symfony - Clase 2
Javier Eguiluz
 
Система рендеринга в Magento
Magecom Ukraine
 
PHP security audits
Damien Seguy
 
Introduzione JQuery
orestJump
 
Maintainable JavaScript 2012
Nicholas Zakas
 
jQuery in 15 minutes
Simon Willison
 
Php Tutorial | Introduction Demo | Basics
Shubham Kumar Singh
 
前端概述
Ethan Zhang
 
jQuery Plugin Creation
benalman
 
Phphacku iitd
Sorabh Jain
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Balázs Tatár
 
jQuery Anti-Patterns for Performance & Compression
Paul Irish
 
jQuery Essentials
Marc Grabanski
 
Plugin jQuery, Design Patterns
Robert Casanova
 
Make your own wp cli command in 10min
Ivelina Dimova
 
Curso Symfony - Clase 2
Javier Eguiluz
 

Viewers also liked (20)

PPTX
Telecommunication system
Jamilah Abbas
 
KEY
Cmsms, open source & business model
Jean-Christophe Cuvelier
 
PDF
세션 하이재킹
Yu Yongwoo
 
PPT
Apache Web Server Architecture Chaitanya Kulkarni
webhostingguy
 
PPTX
Web (HTTP) request to response life cycle
Gopakumar Kunduveetil
 
PPTX
Testing RESTful web services with REST Assured
Bas Dijkstra
 
PPT
Web Cookies
apwebco
 
PDF
Nmap scripting engine
n|u - The Open Security Community
 
PPT
Web Server Technologies I: HTTP & Getting Started
Port80 Software
 
PPT
Smarty sharing-2
Ondo Simanjuntak
 
PDF
Penetration testing
Ammar WK
 
PPT
Hacking A Web Site And Secure Web Server Techniques Used
Siddharth Bhattacharya
 
PPSX
Sessions and cookies
www.netgains.org
 
PPTX
Cookie and session
Aashish Ghale
 
PDF
Web Server Hardening
n|u - The Open Security Community
 
PPT
Mvc architecture
Surbhi Panhalkar
 
PPT
Cookies and sessions
Lena Petsenchuk
 
PDF
Hacking With Nmap - Scanning Techniques
amiable_indian
 
PPTX
REST & RESTful Web Services
Halil Burak Cetinkaya
 
PDF
Basics of telecommunication and networking
Milan Padariya
 
Telecommunication system
Jamilah Abbas
 
Cmsms, open source & business model
Jean-Christophe Cuvelier
 
세션 하이재킹
Yu Yongwoo
 
Apache Web Server Architecture Chaitanya Kulkarni
webhostingguy
 
Web (HTTP) request to response life cycle
Gopakumar Kunduveetil
 
Testing RESTful web services with REST Assured
Bas Dijkstra
 
Web Cookies
apwebco
 
Nmap scripting engine
n|u - The Open Security Community
 
Web Server Technologies I: HTTP & Getting Started
Port80 Software
 
Smarty sharing-2
Ondo Simanjuntak
 
Penetration testing
Ammar WK
 
Hacking A Web Site And Secure Web Server Techniques Used
Siddharth Bhattacharya
 
Sessions and cookies
www.netgains.org
 
Cookie and session
Aashish Ghale
 
Web Server Hardening
n|u - The Open Security Community
 
Mvc architecture
Surbhi Panhalkar
 
Cookies and sessions
Lena Petsenchuk
 
Hacking With Nmap - Scanning Techniques
amiable_indian
 
REST & RESTful Web Services
Halil Burak Cetinkaya
 
Basics of telecommunication and networking
Milan Padariya
 
Ad

Similar to Geek Moot '09 -- Smarty 101 (20)

PDF
Extending CMS Made Simple
cmsmssjg
 
PDF
The web context
Dan Phiffer
 
DOCX
Smarty 3 overview
Gyaneshwar Pardhi
 
PDF
Smarty Template Engine
Mustafa Kırımlı
 
PDF
MTDDC Nagoya 201104
Jun Kaneko
 
PPTX
Word Press As A Cms
Justin Sisley
 
PDF
Blogluck1
Drake Martinet
 
PDF
Sperimentazioni di Tecnologie e Comunicazioni Multimediali: Lezione 5
Salvatore Iaconesi
 
PDF
Industrial training report
Akash Kr Sinha
 
PDF
Smarty 2
guestbea56b
 
PDF
HTML5, just another presentation :)
François Massart
 
PDF
Smarty
Matija Rijavec
 
PDF
Intro to HTML 5 / CSS 3
Tadpole Collective
 
PPS
Web technology html5 php_mysql
durai arasan
 
PDF
Html5 training
James VanDyke
 
PPTX
1 Introduction to Drupal Web Development
Wingston
 
PPTX
WordPress as a CMS
Matthew Vaccaro
 
PDF
HTML5
Cygnet Infotech
 
Extending CMS Made Simple
cmsmssjg
 
The web context
Dan Phiffer
 
Smarty 3 overview
Gyaneshwar Pardhi
 
Smarty Template Engine
Mustafa Kırımlı
 
MTDDC Nagoya 201104
Jun Kaneko
 
Word Press As A Cms
Justin Sisley
 
Blogluck1
Drake Martinet
 
Sperimentazioni di Tecnologie e Comunicazioni Multimediali: Lezione 5
Salvatore Iaconesi
 
Industrial training report
Akash Kr Sinha
 
Smarty 2
guestbea56b
 
HTML5, just another presentation :)
François Massart
 
Intro to HTML 5 / CSS 3
Tadpole Collective
 
Web technology html5 php_mysql
durai arasan
 
Html5 training
James VanDyke
 
1 Introduction to Drupal Web Development
Wingston
 
WordPress as a CMS
Matthew Vaccaro
 
Ad

Recently uploaded (20)

PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
July Patch Tuesday
Ivanti
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 

Geek Moot '09 -- Smarty 101

  • 1. Smarty 101 What? Why? How? Ted Kulp - Shift Refresh, Inc.
  • 3. What? Arguably the most widely used PHP templating system
  • 4. What? Arguably the most widely used PHP templating system Created by Andrei Zmievski
  • 5. What? Arguably the most widely used PHP templating system Created by Andrei Zmievski Tightly integrated into the CMSMS core
  • 6. What? Arguably the most widely used PHP templating system Created by Andrei Zmievski Tightly integrated into the CMSMS core Seamlessly used on all page, module and other templates throughout the system
  • 7. What? Arguably the most widely used PHP templating system Created by Andrei Zmievski Tightly integrated into the CMSMS core Seamlessly used on all page, module and other templates throughout the system Released under the LGPL -- basically means it’s pretty liberally licensed
  • 9. Why? Separates the display logic cleanly from the controller logic
  • 10. Why? Separates the display logic cleanly from the controller logic Much safer by not allowing full range of PHP functionality in a template
  • 11. Why? Separates the display logic cleanly from the controller logic Much safer by not allowing full range of PHP functionality in a template Allows for many tricks to make complicated display easier
  • 12. Why? Separates the display logic cleanly from the controller logic Much safer by not allowing full range of PHP functionality in a template Allows for many tricks to make complicated display easier Get a lot of web-friendly functionality for free
  • 13. Why? Separates the display logic cleanly from the controller logic Much safer by not allowing full range of PHP functionality in a template Allows for many tricks to make complicated display easier Get a lot of web-friendly functionality for free And mainly...
  • 14. Why? Ugly Not So Much <html> <html> <head> <head> <title><?php echo $title; ?></title> <title>{$title}</title> <?php cms_display_stylesheet() ?> {stylesheet} <?php cms_display_metadata() ?> {metdata} </head> </head> <body> <body> <div id=”body”> <div id=”body”> <?php cms_display_content(‘content_en’) ?> {content} </div> </div> <div id=”footer”> <div id=”footer”> <?php printf(‘%m %d %Y’, cms_page_data(‘date_modified’)) ?> {modified_date|cms_date_format} </div> </div> </body> </body> </html> </html> It’s just plain easier to read
  • 17. Absolute musts Literal tags Getting available variables
  • 18. Absolute musts Literal tags Getting available variables Modifiers
  • 22. Literal Tags Escapes javascript Escapes CSS Really... escapes anything with { or } in it. Smarty gets confused
  • 23. Literal Tags Escapes javascript Escapes CSS Really... escapes anything with { or } in it. Smarty gets confused So literal tags basically have Smarty ignore everything between
  • 24. Literal Tags <script type="text/javascript"> / Get all of the tabs and add an onmouseover / / event listener to each tab / var tabs = getElementsByClass('tab', document.getElementById('featuresarea-tabs'),'li') ; for(i=0; i<tabs.length; i++) { ! var this_tab = ! document.getElementById(tabs[i].id); ! this_tab.onmouseover = function(){ ! ! showtab(this.id); ! ! document.getElementById(this.id).className += " selected"; ! }; }! //]]> </script>
  • 25. Literal Tags {literal} <script type="text/javascript"> / Get all of the tabs and add an onmouseover / / event listener to each tab / var tabs = getElementsByClass('tab', document.getElementById('featuresarea-tabs'),'li') ; for(i=0; i<tabs.length; i++) { ! var this_tab = ! document.getElementById(tabs[i].id); ! this_tab.onmouseover = function(){ ! ! showtab(this.id); ! ! document.getElementById(this.id).className += " selected"; ! }; }! //]]> </script> {/literal}
  • 26. The Immortal Question How do I know what variables are available to me in my template?
  • 27. Answer {get_template_vars} !!!!!!!! Gives you all the variables that are available to that template. It’s a must have. Know It Use It Love It
  • 28. {get_template_vars} On a regular page, outputs something like: SCRIPT_NAME = /1.6.x/index.php app_name = CMS sitename = CMS Made Simple Site lang = encoding = utf-8 gCms = Object cgsimple = Object content_obj = Object content_id = 69 page = get_template_vars page_id = get_template_vars page_name = get_template_vars etc.
  • 29. {get_template_vars} On a regular page, outputs something like: SCRIPT_NAME = /1.6.x/index.php app_name = CMS sitename = CMS Made Simple Site lang = encoding = utf-8 gCms = Object cgsimple = Object content_obj = Object content_id = 69 page = get_template_vars page_id = get_template_vars page_name = get_template_vars etc. Which means you can use: {$page_name} in this template and get the page’s name.
  • 31. Modifiers Take output and modifies it directly in Smarty.
  • 32. Modifiers Take output and modifies it directly in Smarty. Allows multiple modifiers to be chained.
  • 33. Modifiers Take output and modifies it directly in Smarty. Allows multiple modifiers to be chained. Format: {$variable|modifier_function:extra:parameters}
  • 34. Modifiers Take output and modifies it directly in Smarty. Allows multiple modifiers to be chained. Format: {$variable|modifier_function:extra:parameters} Chaining: {$variable|modifier_function|another_one:with:params}
  • 35. Modifiers Take output and modifies it directly in Smarty. Allows multiple modifiers to be chained. Format: {$variable|modifier_function:extra:parameters} Chaining: {$variable|modifier_function|another_one:with:params} Smarty comes with a lot of nice modifiers. See chapters 5 and 6 for some examples.
  • 37. Examples {$title|upper} -- Convert the string to upper case
  • 38. Examples {$title|upper} -- Convert the string to upper case {$title|truncate:40:’...’} -- Truncate the string at 40 characters and put an ellipsis on it
  • 39. Examples {$title|upper} -- Convert the string to upper case {$title|truncate:40:’...’} -- Truncate the string at 40 characters and put an ellipsis on it {$smarty.now|date_format:”%Y/%m/%d”} -- Get the current date and give it a nice formatting
  • 40. Examples {$title|upper} -- Convert the string to upper case {$title|truncate:40:’...’} -- Truncate the string at 40 characters and put an ellipsis on it {$smarty.now|date_format:”%Y/%m/%d”} -- Get the current date and give it a nice formatting {$variable|var_dump} -- Any PHP function will work
  • 42. {capture} Allows you capture output of smarty tags and variables and used it elsewhere Useful for testing if something has output data Allows you to get around issues where path of execution isn’t correct
  • 43. {capture} Example Div should only show if there is content {capture name=outp}{content block=‘sideblock’|trim}{/capture} {if $smarty.capture.outp} <div id=”sideblock”> {$smarty.capture.outp} </div> {/if}
  • 44. {cycle} Used to alternate a set of values Useful for alternating classes - ex. Alternating table rows Multiple columns
  • 45. {cycle} Example Split display of items into 2 columns {foreach from=$values item=‘the_item’} <div class=”{cycle values=”col1,col2”}”> {$the_item} </div> {/foreach}
  • 46. {escape} Encodes a variable in various formats -- ex. Encode an email address so that it’s not easily scraped by a spam bot Encode output to make sure it’s valid xhtml
  • 47. {escape} example Make a legible email address more difficult to read via the source. {$user.email|escape:”hexentity”} (Converts [email protected] to %62%64, etc.)
  • 48. Resources http://smarty.net/manual/en (Please read chapters 3 and 4 at a minimum!!!) http://wiki.cmsmadesimple.org