From 7e7d00e1c66fc792fd076877289ff97f45fee7be Mon Sep 17 00:00:00 2001 From: mohrt Date: Thu, 6 Dec 2001 19:30:46 +0000 Subject: [PATCH] added RESOURCES file --- RESOURCES | 12 +++++++++ docs.sgml | 73 +++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 RESOURCES diff --git a/RESOURCES b/RESOURCES new file mode 100644 index 00000000..5b331e6e --- /dev/null +++ b/RESOURCES @@ -0,0 +1,12 @@ +Smarty Resources on the Web: + +Home Page: +http://www.phpinsider.com/php/code/Smarty + +Tutorials: +http://www.zend.com/zend/tut/tutsweatpart1.php + +Misc: +http://freshmeat.net/projects/smarty/ +http://www.hotscripts.com/Detailed/8817.html + diff --git a/docs.sgml b/docs.sgml index 52d2bcb1..42731d7b 100644 --- a/docs.sgml +++ b/docs.sgml @@ -144,7 +144,7 @@ linkend="setting.cache.lifetime">expires, regenerating a new one. The default cache expire time can be configured from the class. The exception to the rule is the insert tag. Anything + linkend="builtin.functions.insert">insert tag. Anything generated by the insert tag is not cached, but run dynamically on every invocation, even within cached content. @@ -472,7 +472,7 @@ require_once(SMARTY_DIR."Smarty.class.php"); $insert_tag_check If you have $caching enabled and you do not use the insert tag anywhere in + linkend="builtin.functions.insert">insert tag anywhere in your templates, set this to false. This saves the insert tag search, speeding up cached page fetches. @@ -503,7 +503,7 @@ require_once(SMARTY_DIR."Smarty.class.php"); This tells Smarty how to handle PHP code embedded in the tempalates. There are four possible settings, default being SMARTY_PHP_PASSTHRU. Note that this does NOT affect php code - within {php}{/php} + within {php}{/php} tags in the template. @@ -2101,7 +2101,7 @@ pass=foobar are integral to the template language. You cannot create custom functions with the same names, nor can you modify built-in functions. - + capture capture is used to collect the output of the template into a @@ -2266,7 +2266,7 @@ pass=foobar - + include @@ -2317,9 +2317,10 @@ pass=foobar the attribute "file", which contains the template resource path. - You an optionally pass the assign attribute, which will specify a - template variable name that the output of include will be assigned - to instead of displayed. This was added to Smarty 1.5.0. + You an optionally pass the assign attribute, + which will specify a template variable name that the output of + include will be assigned to instead of + displayed. This was added to Smarty 1.5.0. function include @@ -2352,7 +2353,7 @@ pass=foobar - + include_php @@ -2407,9 +2408,10 @@ pass=foobar before hand. - You an optionally pass the assign attribute, which will specify a - template variable name that the output of include_php will be - assigned to instead of displayed. + You an optionally pass the assign attribute, + which will specify a template variable name that the output of + include will be assigned to instead of + displayed. include_php was added to Smarty 1.5.0. @@ -2445,7 +2447,7 @@ index.tpl - + insert @@ -2656,7 +2658,7 @@ OUTPUT: - + literal Literal tags allow a block of data to be taken literally, @@ -2690,7 +2692,7 @@ OUTPUT: - + php php tags allow php to be embedded directly into the template. They @@ -6094,6 +6096,47 @@ Pretty easy isn't it? Stock Name: {$ticker_name} Stock Price: {$ticker_price} + + + + As of Smarty 1.5.0, there is even a cleaner way. You can include php in + your templates with the {include_php ...} tag. This way you can keep + your PHP logic separated from the template logic. See the include_php function for + more information. + + +componentized template with include_php + + +load_ticker.php +--------------- + +<?php + // setup our function for fetching stock data + function fetch_ticker($symbol,&$ticker_name,&$ticker_price) { + // put logic here that fetches $ticker_name + // and $ticker_price from some resource + } + + // call the function + fetch_ticker("YHOO",$ticker_name,$ticker_price); + + // assign template variables + $this->assign("ticker_name",$ticker_name); + $this->assign("ticker_price",$ticker_price); +?> + + +index.tpl +--------- + +{* Smarty *} + +{include_php file="load_ticker.php"} + +Stock Name: {$ticker_name} Stock Price: {$ticker_price} +