Miscellaneous

  Home arrow Miscellaneous arrow Page 3 - Smarty for Beginners
MISCELLANEOUS

Smarty for Beginners
By: Hermawan Haryanto
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 156
    2003-12-28

    Table of Contents:
  • Smarty for Beginners
  • File Creation
  • The Basics
  • What about accessing a database?
  • Some fun stuff

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Smarty for Beginners - The Basics


    (Page 3 of 5 )

    The basic operation of a template engine is to assign variables or arrays and integrate them with your html page.

    Let's try something simple first. Open your index.php page and add this line before the $smarty->display function.

    $smarty->assign ("name", "Hermawan Haryanto");

    Open your index.html page and add this line:

    My name is {$name}

    The result would be:

    My name is Hermawan Haryanto

    Now, let's try assigning arrays to your template. Add these lines in index.php remembering all added lines would be before the $smarty->display function.

    $friends = array("Mike", "Simpson", "Bill", "Torvald", "Paul", "John Doe");
    $smarty->assign ("friends", $friends);

    Open your index.html page and add these lines:

    Friends List:
    {section name=i loop=$friends}
      {$friends[i]}<br>
    {/section}

    You'll see the array is pulled and populated on the html page.

    More Miscellaneous Articles
    More By Hermawan Haryanto

    blog comments powered by Disqus

    MISCELLANEOUS ARTICLES

    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength
    - Install Slackware on Your Old PC


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap