From 41448a1555ee109df83b26f0ca4cf91db375cf1f Mon Sep 17 00:00:00 2001 From: mohrt Date: Thu, 1 Nov 2001 21:52:46 +0000 Subject: [PATCH] update QUICKSTART guide with index key example --- QUICKSTART | 27 +++++++++++++++++++++++++++ demo/index.php | 2 -- docs.sgml | 2 +- index.php | 2 -- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/QUICKSTART b/QUICKSTART index 9544dd8f..511bd4d0 100644 --- a/QUICKSTART +++ b/QUICKSTART @@ -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 -------- +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}
+ {sectionelse} + There are no values to loop through. + {/section} +

+ There were {%people.loop%} names in this list. +{include file="footer.tpl"} + + You can also do complex nested sections, like so: --------- index.php -------- diff --git a/demo/index.php b/demo/index.php index d3246dde..5acebb36 100644 --- a/demo/index.php +++ b/demo/index.php @@ -1,7 +1,5 @@ clear_all_cache(); clear_compiled_tpl - void clear_all_cache + void clear_compiled_tpl string tpl_file diff --git a/index.php b/index.php index d3246dde..5acebb36 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,5 @@