From bd4ad753d7bf6bf6a98c989fff4aed9273316156 Mon Sep 17 00:00:00 2001 From: mohrt Date: Mon, 15 Apr 2002 19:01:48 +0000 Subject: [PATCH] update docs, get modifiers and functions into index for easy access --- docs/designers.sgml | 293 +++++++++++++++++++++----------------------- 1 file changed, 140 insertions(+), 153 deletions(-) diff --git a/docs/designers.sgml b/docs/designers.sgml index 9a87a542..a8e8a7b8 100644 --- a/docs/designers.sgml +++ b/docs/designers.sgml @@ -1,14 +1,7 @@ Smarty For Template Designers - - Template Language - - The templates are the language of Smarty. These are the files that the designers - work with. They're basically pages made up of static content interspersed with - template markup tags. These tags are placeholders for variables or blocks of logic. - - + Basic Syntax All Smarty template tags are enclosed within delimiters. By @@ -23,7 +16,7 @@ place. - + Comments Template comments are surrounded by asterisks, and that is surrounded @@ -48,9 +41,9 @@ {html_options values=$vals selected=$selected output=$output} </SELECT> - + - + Functions Each Smarty tag either prints a @@ -83,9 +76,9 @@ your liking, or you can add new ones. html_options and html_select_date are examples of custom functions. - + - + Attributes Most of the functions take attributes that specify or modify @@ -116,11 +109,11 @@ {html_options values=$vals selected=$selected output=$output} </SELECT> - + - + - + Variables Smarty has several different types of variables, all of which are @@ -141,7 +134,7 @@ <body bgcolr="{#bgcolor#}"> - + Variables assigned from PHP Variables that are assigned from PHP are referenced by preceding @@ -162,7 +155,7 @@ Hello Doug, glad to see you could make it. Your last login was on January 11th, 2001. - + Associative arrays You can also reference associative array variables that are @@ -186,8 +179,8 @@ zaphod@slartibartfast.com<br> 555-111-1234<br> - - + + Array indexes You can reference arrays by their index, much like native PHP @@ -202,8 +195,8 @@ zaphod@slartibartfast.com<br> {$Contacts[0][0]}<br> {$Contacts[0][1]}<br> - - + + Objects Properties of objects assigned from PHP can be referenced @@ -220,10 +213,10 @@ OUTPUT: name: Zaphod Beeblebrox<br> email: zaphod@slartibartfast.com<br> - - + + - + Variables loaded from config files Variables that are loaded from the config files are referenced by enclosing @@ -252,16 +245,16 @@ email: zaphod@slartibartfast.com<br> explained later in this document under config_load. - + - + {$smarty} reserved variable The reserved {$smarty} variable can be used to access several special template variables. The full list of them follows. - + Request variables The request variables such as get, post, cookies, server, @@ -293,9 +286,9 @@ email: zaphod@slartibartfast.com<br> {* display the variable "username" from merged get/post/cookies/server/env *} {$smarty.request.username} - + - + Current timestamp The current timestamp can be accessed with {$smarty.now}. The @@ -310,18 +303,18 @@ email: zaphod@slartibartfast.com<br> {* use the date_format modifier to show current date and time *} {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"} - + - + Output capture buffer The output captured via {capture}..{/capture} construct can be accessed using {$smarty} variable. See section on capture for an example. - + - + Loop properties {$smarty} variable can be used to refer to 'section' and @@ -329,11 +322,11 @@ email: zaphod@slartibartfast.com<br> section and foreach. - - + + - + Variable Modifiers Variable modifiers can be applied to any variable to alter its contents. To @@ -360,9 +353,7 @@ Topic: {$topic|truncate:40:"..."} elements in the $articleTitle array.) - - Built-in Modifiers - + capitalize This is used to capitalize the first letter of all words in a variable. @@ -378,8 +369,8 @@ OUTPUT: Police begin campaign to rundown jaywalkers. Police Begin Campaign To Rundown Jaywalkers. - - + + count_characters This is used to count the number of characters in a variable. @@ -396,8 +387,8 @@ OUTPUT: Cold Wave Linked to Temperatures 32 - - + + count_paragraphs This is used to count the number of paragraphs in a variable. @@ -416,8 +407,8 @@ War Dims Hope for Peace. Child's Death Ruins Couple's Holiday. Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation. 2 - - + + count_sentences This is used to count the number of sentences in a variable. @@ -434,8 +425,8 @@ OUTPUT: Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe. 2 - - + + count_words This is used to count the number of words in a variable. @@ -452,8 +443,8 @@ OUTPUT: Dealers Will Hear Car Talk at Noon. 7 - - + + date_format @@ -589,8 +580,8 @@ on your system's strftime() function where PHP was compiled. Check your system's manpage for a full list of valid specifiers. - - + + default @@ -635,8 +626,8 @@ OUTPUT: no title - - + + escape @@ -699,8 +690,8 @@ OUTPUT: <a href="mailto:%62%6f%62%40%6d%65%2e%6e%65%74">&#x62;&#x6f;&#x62;&#x40;&#x6d;&#x65;&#x2e;&#x6e;&#x65;&#x74;</a> - - + + indent @@ -772,8 +763,8 @@ Statistics show that teen pregnancy drops off significantly after 25. Sun or rain expected today, dark tonight. Statistics show that teen pregnancy drops off significantly after 25. - - + + lower This is used to lowercase a variable. @@ -789,8 +780,8 @@ OUTPUT: Two Convicts Evade Noose, Jury Hung. two convicts evade noose, jury hung. - - + + regex_replace @@ -847,8 +838,8 @@ Infertility unlikely to be passed on, experts say Infertility unlikely to be passed on, experts say - - + + replace @@ -900,8 +891,8 @@ Child's Stool Great for Use in Garden. Child's Stool Great for Use in Vineyard. Child's Stool Great for Use in Garden. - - + + spacify @@ -948,8 +939,8 @@ Something Went Wrong in Jet Crash, Experts Say. S o m e t h i n g W e n t W r o n g i n J e t C r a s h , E x p e r t s S a y . S^^o^^m^^e^^t^^h^^i^^n^^g^^ ^^W^^e^^n^^t^^ ^^W^^r^^o^^n^^g^^ ^^i^^n^^ ^^J^^e^^t^^ ^^C^^r^^a^^s^^h^^,^^ ^^E^^x^^p^^e^^r^^t^^s^^ ^^S^^a^^y^^. - - + + string_format @@ -995,8 +986,8 @@ OUTPUT: 23.58 24 - - + + strip_tags This strips out markup tags, basically anything between < and >. @@ -1012,8 +1003,8 @@ OUTPUT: Blind Woman Gets <font face="helvetica">New Kidney</font> from Dad she Hasn't Seen in <b>years</b>. Blind Woman Gets New Kidney from Dad she Hasn't Seen in years. - - + + truncate @@ -1088,8 +1079,8 @@ Two Sisters Reunite after--- Two Sisters Reunite after Eigh Two Sisters Reunite after E... - - + + upper This is used to uppercase a variable. @@ -1105,8 +1096,8 @@ OUTPUT: If Strike isn't Settled Quickly it may Last a While. IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE. - - + + wordwrap @@ -1192,10 +1183,11 @@ Blind woman gets new kidney fr om dad she hasn't seen in years. - - + - + + + Combining Modifiers You can apply as many modifiers as you like to a variable. The modifiers @@ -1221,17 +1213,17 @@ s m o k e r s a r e p r o d u c t i v e , b u t d e a t h c u t s... s m o k e r s a r e p r o d u c t i v e , b u t . . . s m o k e r s a r e p. . . - - + - + + Built-in Functions Smarty comes with several built-in functions. Built-in functions 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 @@ -1275,8 +1267,8 @@ s m o k e r s a r e p. . . {/if} - - + + config_load @@ -1393,8 +1385,8 @@ s m o k e r s a r e p. . . </body> </html> - - + + include @@ -1495,8 +1487,8 @@ s m o k e r s a r e p. . . {* include from template resource named "db" *} {include file="db:header.tpl"} - - + + include_php @@ -1586,8 +1578,8 @@ index.tpl <a href="{$curr_section.url}">{$curr_section.name}</a><br> {/foreach} - - + + insert @@ -1705,8 +1697,8 @@ index.tpl weather, search results, user feedback areas, etc. - - + + if,elseif,else if statements in Smarty have much the same flexibility as php if @@ -1785,8 +1777,8 @@ index.tpl ... {/if} - - + + ldelim,rdelim ldelim and rdelim are used for displaying the literal delimiter, in @@ -1805,8 +1797,8 @@ OUTPUT: {funcname} is how functions look in Smarty! - - + + literal Literal tags allow a block of data to be taken literally, @@ -1837,8 +1829,8 @@ OUTPUT: </script> {/literal} - - + + php php tags allow php to be embedded directly into the template. They @@ -1856,8 +1848,8 @@ OUTPUT: include("/path/to/display_weather.php"); {/php} - - + + section,sectionelse @@ -2101,7 +2093,7 @@ e-mail: jane@mydomain.com<p> supported, but you will only see reference to the new syntax in the manual examples. - + index index is used to display the current loop index, starting with zero @@ -2131,8 +2123,8 @@ e-mail: jane@mydomain.com<p> 2 id: 1002<br> - - + + index_prev index_prev is used to display the previous loop index. @@ -2160,8 +2152,8 @@ e-mail: jane@mydomain.com<p> The customer id changed<br> - - + + index_next index_next is used to display the next loop index. On the last @@ -2190,8 +2182,8 @@ e-mail: jane@mydomain.com<p> The customer id will change<br> - - + + iteration iteration is used to display the current loop iteration. @@ -2229,8 +2221,8 @@ e-mail: jane@mydomain.com<p> The customer id will change<br> - - + + first first is set to true if the current section iteration is the first @@ -2262,8 +2254,8 @@ e-mail: jane@mydomain.com<p> </table> - - + + last last is set to true if the current section iteration is the last @@ -2295,8 +2287,8 @@ e-mail: jane@mydomain.com<p> </table> - - + + rownum rownum is used to display the current loop iteration, @@ -2317,8 +2309,8 @@ e-mail: jane@mydomain.com<p> 3 id: 1002<br> - - + + loop loop is used to display the last index number that this section @@ -2342,8 +2334,8 @@ e-mail: jane@mydomain.com<p> There were 3 customers shown above. - - + + show show is used as a parameter to section. @@ -2376,8 +2368,8 @@ e-mail: jane@mydomain.com<p> the section was shown. - - + + total total is used to display the number of iterations that this section @@ -2404,9 +2396,9 @@ e-mail: jane@mydomain.com<p> There were 3 customers shown above. - - - + + + foreach,foreachelse @@ -2519,8 +2511,8 @@ phone: 555-4444<br> fax: 555-3333<br> cell: 760-1234<br> - - + + strip Many times web designers @@ -2564,19 +2556,16 @@ OUTPUT: If you have plain text at the beginning or end of any line, they will be run together, and may not be desired results. - - + + - - Custom Functions + + Custom Functions Smarty comes with several custom functions that you can use in the templates. - - - Custom Functions - + assign @@ -2630,8 +2619,8 @@ OUTPUT: The value of $name is Bob. - - + + counter @@ -2727,8 +2716,8 @@ OUTPUT: 6<br> 8<br> - - + + eval @@ -2824,8 +2813,8 @@ You must supply a <b>state</b>. - - + + fetch @@ -2909,8 +2898,8 @@ You must supply a <b>state</b>. <b>{$weather}</b> {/if} - - + + html_options @@ -2999,8 +2988,8 @@ OUTPUT: <option value="1003">Charlie Brown</option> </select> - - + + html_select_date @@ -3283,8 +3272,8 @@ OUTPUT: (current year is 2000) <option value="2001">2001</option> </select> - - + + html_select_time @@ -3544,8 +3533,8 @@ OUTPUT: <option value="pm">PM</option> </select> - - + + math @@ -3658,8 +3647,8 @@ OUTPUT: 9.44 - - + + popup_init popup is an integration of overLib, a library used for popup @@ -3673,8 +3662,8 @@ OUTPUT: This was added to Smarty 1.4.4. - - + + popup @@ -4084,10 +4073,8 @@ OUTPUT: (See the Smarty official web site for working examples.) - - - - + + Config Files