more linking and WS from Peter

This commit is contained in:
nlopess
2005-05-27 16:25:02 +00:00
parent 3086de700b
commit 26b3e5489e
78 changed files with 1400 additions and 727 deletions

View File

@@ -3,28 +3,53 @@
<sect1 id="language.assigned.variables">
<title>Variables assigned from PHP</title>
<para>
Variables that are assigned from PHP are referenced by preceding them with
a dollar sign <literal>$</literal>. Variables assigned from within the
Variables that are
<link linkend="api.assign">assigned</link> from PHP are referenced by preceding them with
a dollar sign <literal>$</literal>. Variables assigned from within a
template with the <link linkend="language.function.assign">{assign}</link>
function are also displayed this way.
</para>
<example>
<title>assigned variables</title>
<programlisting>
<para> php script</para>
<programlisting role="php">
<![CDATA[
Hello {$firstname}, glad to see you could make it.
<br />
Your last login was on {$lastLoginDate}.
<?php
$smarty = new Smarty;
$smarty->assign('firstname', 'Doug');
$smarty->assign('lastname', 'Evans');
$smarty->assign('meetingPlace', 'New York');
$smarty->display('index.tpl');
?>
]]>
</programlisting>
</programlisting>
<para>
where the content of index.tpl is:
</para>
<programlisting>
<![CDATA[
Hello {$firstname} {$lastname}, glad to see you can make it.
<br />
{* this will not work as $vars are case sensitive *}
This weeks meeting is in {$meetingplace}.
{* this will work *}
This weeks meeting is in {$meetingPlace}.
]]>
</programlisting>
<para>
This will output:
</para>
<screen>
<![CDATA[
Hello Doug, glad to see you could make it.
Hello Doug Evans, glad to see you can make it.
<br />
Your last login was on January 11th, 2001.
This weeks meeting is in .
This weeks meeting is in New York.
]]>
</screen>
</example>
@@ -40,7 +65,6 @@ Your last login was on January 11th, 2001.
<programlisting role="php">
<![CDATA[
<?php
$smarty = new Smarty;
$smarty->assign('Contacts',
array('fax' => '555-222-9876',
'email' => 'zaphod@slartibartfast.com',
@@ -66,7 +90,7 @@ $smarty->display('index.tpl');
this will output:
</para>
<screen>
<![CDATA[
<![CDATA[
555-222-9876<br />
zaphod@slartibartfast.com<br />
555-444-3333<br />
@@ -87,12 +111,12 @@ zaphod@slartibartfast.com<br />
<![CDATA[
<?php
$smarty = new Smarty;
$smarty->assign('Contacts',
array('555-222-9876',
'zaphod@slartibartfast.com',
array('555-444-3333',
'555-111-1234')));
$smarty->assign('Contacts', array(
'555-222-9876',
'zaphod@slartibartfast.com',
array('555-444-3333',
'555-111-1234')
));
$smarty->display('index.tpl');
?>

View File

@@ -86,13 +86,17 @@ rowBgColor = "#cccccc"
]]>
</screen>
</example>
<para>
Config file variables cannot be used until
after they are loaded in from a config file. This procedure is
explained later in this document under <link linkend="api.config.load"><command>config_load</command></link>.
</para>
<para>See also <link linkend="language.syntax.variables">Variables</link> and <link linkend="language.variables.smarty">$smarty reserved
variables</link></para>
<para>
Config file variables cannot be used until
after they are loaded in from a config file. This procedure is
explained later in this document under
<link linkend="language.function.config.load"><command>{config_load}</command></link>.
</para>
<para>
See also <link linkend="language.syntax.variables">Variables</link> and
<link linkend="language.variables.smarty">$smarty reserved
variables</link>
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
@@ -113,4 +117,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
-->

View File

@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.variables.smarty">
<title>{$smarty} reserved variables</title>
<title>{$smarty} reserved variable</title>
<para>
The reserved {$smarty} variable can be used to access several
special template variables. The full list of them follows.
</para>
<sect2 id="language.variables.smarty.request">
<title>Request variables</title>
<para>
The request variables such as get, post, cookies, server,
environment, and session variables can be accessed as demonstrated
in the examples below:
</para>
<example>
<title>displaying request variables</title>
<programlisting>
<sect2 id="language.variables.smarty.request">
<title>Request variables</title>
<para>
The <ulink url="&url.php-manual;reserved.variables">request variables
</ulink> such as $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV and $_SESSION
can be accessed as demonstrated in the examples below:
</para>
<example>
<title>displaying request variables</title>
<programlisting>
<![CDATA[
{* display value of page from URL (GET) http://www.example.com/index.php?page=foo *}
{$smarty.get.page}
@@ -39,25 +39,27 @@
{* display the variable "username" from merged get/post/cookies/server/env *}
{$smarty.request.username}
]]>
</programlisting>
</example>
<note>
<para>
For historical reasons {$SCRIPT_NAME} can be accessed
directly though {$smarty.server.SCRIPT_NAME} is the
proposed way to access this value.
</para>
</note>
</sect2>
</programlisting>
</example>
<note>
<para>
For historical reasons {$SCRIPT_NAME} can be accessed
directly, although {$smarty.server.SCRIPT_NAME} is the
proposed way to access this value.
</para>
</note>
</sect2>
<sect2 id="language.variables.smarty.now">
<title>{$smarty.now}</title>
<para>
The current timestamp can be accessed with {$smarty.now}. The
number reflects the number of seconds passed since the so-called
Epoch (January 1, 1970) and can be passed directly to
<link linkend="language.modifier.date.format">date_format</link> modifier for display purposes.
</para>
<sect2 id="language.variables.smarty.now">
<title>{$smarty.now}</title>
<para>
The current <ulink url="&url.php-manual;function.time">timestamp</ulink>
can be accessed with {$smarty.now}. The number reflects the number of
seconds passed since the so-called Epoch (January 1, 1970)
and can be passed directly to the
<link linkend="language.modifier.date.format">date_format</link>
modifier for display purposes.
</para>
<example>
<title>using {$smarty.now}</title>
<programlisting>
@@ -169,3 +171,4 @@ vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->