update QUICKSTART guide with index key example

This commit is contained in:
mohrt
2001-11-01 21:52:46 +00:00
parent fdfd1843d0
commit 41448a1555
4 changed files with 28 additions and 5 deletions

View File

@@ -259,6 +259,33 @@ the section that display the loop iteration and the total number of times the
section is looped. Also note the {sectionelse}. This would have been displayed
had the loop array $FirstName been empty.
You can access keys of arrays with this syntax:
--------- index.php --------
<?php
require("Smarty.class.php");
$smarty = new Smarty;
$smarty->assign(array("ContactInfo" => array(
array("FirstName" => "Ned","LastName" => "Flanders"),
array("FirstName" => "Monty","LastName" => "Burns")
)
));
$smarty->display("index.tpl");
?>
--------- templates/index.tpl --------
{include file="header.tpl" title="Home Page"}
{section name=people loop=$ContactInfo}
{$ContactInfo[people].FirstName}
{$ContactInfo[people].LastName}<br>
{sectionelse}
There are no values to loop through.
{/section}
<p>
There were {%people.loop%} names in this list.
{include file="footer.tpl"}
You can also do complex nested sections, like so:
--------- index.php --------

View File

@@ -1,7 +1,5 @@
<?php
error_reporting(E_ALL);
require("Smarty.class.php");
$smarty = new Smarty;

View File

@@ -812,7 +812,7 @@ $smarty->clear_all_cache();
<title>clear_compiled_tpl</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>clear_all_cache</function></funcdef>
<funcdef>void <function>clear_compiled_tpl</function></funcdef>
<paramdef>string <parameter>tpl_file</parameter></paramdef>
</funcprototype>
</funcsynopsis>

View File

@@ -1,7 +1,5 @@
<?php
error_reporting(E_ALL);
require("Smarty.class.php");
$smarty = new Smarty;