This commit is contained in:
pete_morgan
2006-02-18 13:18:16 +00:00
parent baa6910c46
commit aabfda3c63
9 changed files with 52 additions and 55 deletions

View File

@@ -21,8 +21,7 @@
<programlisting>
<![CDATA[
{* the long way *}
{if $title eq ""}
{if $title eq ''}
&nbsp;
{else}
{$title}
@@ -30,8 +29,7 @@
{* the short way *}
{$title|default:"&nbsp;"}
{$title|default:'&nbsp;'}
]]>
</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 @@ Jan 4, 2001
</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>

View File

@@ -57,7 +57,7 @@
Be careful when capturing <link
linkend="language.function.insert">{insert}</link>
output. If you have
<link linkend="caching">caching</link>
<link linkend="caching">$caching</link>
enabled and you have
<link linkend="language.function.insert">{insert}</link>
commands that you expect to run
@@ -93,13 +93,13 @@
<link linkend="language.function.popup">{popup}</link>
function</para>
<programlisting>
<![CDATA[
{capture name=some_content assign=popText}
.... some content ....
{/capture}
<a href="#" {popup caption='Help' text=$popText}>help</a>
]]>
<![CDATA[
{capture name=some_content assign=popText}
.... some popup content ....
{/capture}
<a href="#" {popup caption='Help' text=$popText}>help</a>
]]>
</programlisting>
</example>

View File

@@ -63,7 +63,7 @@
<para>
{include_php} tags are used to include a php script in your template.
If <link linkend="variable.security">security is enabled</link>,
If <link linkend="variable.security">$security</link> is enabled,
then the php script must be located in the <link
linkend="variable.trusted.dir">$trusted_dir</link> path.
The {include_php} tag must have the attribute
@@ -97,9 +97,9 @@
<?php
// load in variables from a mysql db and assign them to the template
require_once("MySQL.class.php");
require_once('MySQL.class.php');
$sql = new MySQL;
$sql->query("select * from site_nav_sections order by name",SQL_ALL);
$sql->query('select * from site_nav_sections order by name',SQL_ALL);
$this->assign('sections',$sql->record);
?>
@@ -111,7 +111,7 @@ $this->assign('sections',$sql->record);
<programlisting>
<![CDATA[
{* absolute path, or relative to $trusted_dir *}
{include_php file="/path/to/load_nav.php"}
{include_php file='/path/to/load_nav.php'}
{foreach item="curr_section" from=$sections}
<a href="{$curr_section.url}">{$curr_section.name}</a><br />

View File

@@ -6,7 +6,8 @@
{include} tags are used for including other templates in the current
template. Any variables available in the current template are also
available within the included template. The {include} tag must have
the attribute "file", which contains the template resource path.
the attribute <emphasis>'file'</emphasis>,
which contains the template resource path.
</para>
<para>
You can optionally pass the <emphasis>'assign'</emphasis> attribute,

View File

@@ -19,9 +19,9 @@
<note>
<title>Technical Note</title>
<para>
{strip}{/strip} does not affect the contents of template variables.
See the
<link linkend="language.modifier.strip">strip modifier</link>.
{strip}{/strip} does not affect the contents of template variables,
see the
<link linkend="language.modifier.strip">strip modifier</link> instead.
</para>
</note>
<example>

View File

@@ -33,7 +33,7 @@ $smarty->display('index.tpl');
<![CDATA[
{$articleTitle}
{$articleTitle|strip}
{$articleTitle|strip:"&nbsp;"}
{$articleTitle|strip:'&nbsp;'}
]]>
</programlisting>
<para>

View File

@@ -16,7 +16,7 @@
</methodsynopsis>
<para>
This only works if <link
linkend="variable.caching">$caching</link> is set to true. See also the
linkend="variable.caching">$caching</link> is set to true; see the
<link linkend="caching">caching section</link>.
</para>
<example>

View File

@@ -6,7 +6,7 @@
<refpurpose>dynamically register resources</refpurpose>
</refnamediv>
<refsect1>
<title>Descrption</title>
<title>Description</title>
<methodsynopsis>
<type>void</type><methodname>register_resource</methodname>
<methodparam><type>string</type><parameter>name</parameter></methodparam>

View File

@@ -8,11 +8,11 @@
or <link linkend="api.fetch">fetch()</link>.
Let's say that a call to display('index.tpl') may have several
different output contents depending on some condition, and you want
separate caches for each one. You can do this by passing a cache_id as the
separate caches for each one. You can do this by passing a $cache_id as the
second parameter to the function call.
</para>
<example>
<title>passing a cache_id to display()</title>
<title>passing a $cache_id to display()</title>
<programlisting role="php">
<![CDATA[
<?php