cvs: smarty /docs/en/appendixes tips.xml
[email protected] ("Peter 'Mash' Morgan") Sat, 18 Feb 2006 13:17:11 -0000
| Newsgroups | php.smarty.cvs |
|---|---|
| Message-ID | <cvspete_morgan1140268631@cvsserver> |
pete_morgan Sat Feb 18 13:17:11 2006 UTC
Modified files:
/smarty/docs/en/appendixes tips.xml
Log:
tweaks
http://cvs.php.net/viewcvs.cgi/smarty/docs/en/appendixes/tips.xml?r1=1.9&r2=1.10&diff_format=u
Index: smarty/docs/en/appendixes/tips.xml
diff -u smarty/docs/en/appendixes/tips.xml:1.9 smarty/docs/en/appendixes/tips.xml:1.10
--- smarty/docs/en/appendixes/tips.xml:1.9 Sun Jun 5 15:47:24 2005
+++ smarty/docs/en/appendixes/tips.xml Sat Feb 18 13:17:11 2006
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.9 $ -->
+<!-- $Revision: 1.10 $ -->
<chapter id="tips">
<title>Tips & Tricks</title>
<para>
@@ -21,8 +21,7 @@
<programlisting>
<![CDATA[
{* the long way *}
-
-{if $title eq ""}
+{if $title eq ''}
{else}
{$title}
@@ -30,8 +29,7 @@
{* the short way *}
-
-{$title|default:" "}
+{$title|default:' '}
]]>
</programlisting>
</example>
@@ -54,7 +52,7 @@
<programlisting>
<![CDATA[
{* do this somewhere at the top of your template *}
-{assign var="title" value=$title|default:"no title"}
+{assign var='title' value=$title|default:'no title'}
{* if $title was empty, it now contains the value "no title" when you print it *}
{$title}
@@ -74,7 +72,8 @@
is common to split those out into their own templates and
<link linkend="language.function.include">{include}</link> them.
But what if the header needs to have a different title, depending on
- what page you are coming from? You can pass the title to the header when
+ what page you are coming from? You can pass the title to the header
+ as an <link linkend="language.syntax.attributes">attribute</link> when
it is included.
</para>
@@ -82,38 +81,45 @@
<title>Passing the title variable to the header template</title>
<para>
- <filename>mainpage.tpl</filename>
+ <filename>mainpage.tpl</filename> - When the main page is drawn, the title of "Main Page" is passed to the
+ <filename>header.tpl</filename>, and will subsequently be used as the title.
</para>
<programlisting>
<![CDATA[
-
-{include file="header.tpl" title="Main Page"}
+{include file='header.tpl' title='Main Page'}
{* template body goes here *}
-{include file="footer.tpl"}
+{include file='footer.tpl'}
]]>
</programlisting>
<para>
- <filename>archives.tpl</filename>
+ <filename>archives.tpl</filename> - When the
+ archives page is drawn, the title will be "Archives". Notice in the
+ archive example, we are using a variable from the
+ <filename>archives_page.conf</filename>
+ file instead of a hard coded variable.
</para>
<programlisting>
<![CDATA[
-{config_load file="archive_page.conf"}
-{include file="header.tpl" title=#archivePageTitle#}
+{config_load file='archive_page.conf'}
+{include file='header.tpl' title=#archivePageTitle#}
{* template body goes here *}
-{include file="footer.tpl"}
+{include file='footer.tpl'}
]]>
</programlisting>
<para>
- <filename>header.tpl</filename>
+ <filename>header.tpl</filename> - Notice that "BC News" is
+ printed if the $title variable is not set, using the
+ <link linkend="language.modifier.default">default</link>
+ variable modifier.
</para>
<programlisting>
<![CDATA[
<html>
<head>
-<title>{$title|default:"BC News"}</title>
+<title>{$title|default:'BC News'}</title>
</head>
<body>
]]>
@@ -129,27 +135,17 @@
]]>
</programlisting>
</example>
-
- <para>
- When the main page is drawn, the title of "Main Page" is passed to the
- <filename>header.tpl</filename>, and will subsequently be used as the title. When the
- archives page is drawn, the title will be "Archives". Notice in the
- archive example, we are using a variable from the
- <filename>archives_page.conf</filename>
- file instead of a hard coded variable. Also notice that "BC News" is
- printed if the $title variable is not set, using the
- <link linkend="language.modifier.default">default</link>
- variable modifier.
- </para>
</sect1>
+
<sect1 id="tips.dates">
<title>Dates</title>
<para>
- As a rule of thumb, always pass dates to Smarty as timestamps. This
- allows template designers to use <link
- linkend="language.modifier.date.format">date_format</link> for full
- control over date formatting, and also makes it easy to compare dates if
- necessary.
+ As a rule of thumb, always pass dates to Smarty as
+ <ulink url="&url.php-manual;time">timestamps</ulink>. This
+ allows template designers to use the <link
+ linkend="language.modifier.date.format">date_format</link> modifier
+ for full control over date formatting, and also makes it easy to
+ compare dates if necessary.
</para>
<note>
<para>
@@ -196,7 +192,7 @@
</example>
<para>
When using <link linkend="language.function.html.select.date">{html_select_date}</link>
- in a template, The programmer will most
+ in a template, the programmer will most
likely want to convert the output from the form back into timestamp
format. Here is a function to help you with that.
</para>