mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-28 02:41:37 +01:00
sync with EN
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.5 Maintainer: yannick Status: ready -->
|
||||
<!-- EN-Revision: 1.7 Maintainer: yannick Status: ready -->
|
||||
|
||||
<refentry id="api.fetch">
|
||||
<refnamediv>
|
||||
<refname>fetch</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>fetch()</refname>
|
||||
<refpurpose>Retourne le r<>sultat du template</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>string</type><methodname>fetch</methodname>
|
||||
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>string</type><parameter>$compile_id</parameter>
|
||||
</methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Utilis<69>e pour renvoyer le r<>sultat du template plut<75>t que de l'afficher.
|
||||
Utilis<69>e pour renvoyer le r<>sultat du template plut<75>t que de
|
||||
l'<link linkend="api.display">afficher</link>.
|
||||
Il faut passer un type et un chemin de <link
|
||||
linkend="template.resources">ressource template</link>
|
||||
valides. Vous pouvez passer un identifiant de cache en deuxi<78>me
|
||||
@@ -23,38 +26,39 @@
|
||||
</link> pour plus de renseignements.
|
||||
</para>
|
||||
¶meter.compileid;
|
||||
|
||||
<para>
|
||||
<example>
|
||||
<title>Exemple avec fetch</title>
|
||||
<title>Exemple avec fetch()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include("Smarty.class.php");
|
||||
include('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
|
||||
$smarty->caching = true;
|
||||
|
||||
// ne fait un appel <20> la base de donn<6E>es que si le fichier
|
||||
// de cache n'existe pas
|
||||
if(!$smarty->is_cached("index.tpl"))
|
||||
if(!$smarty->is_cached('index.tpl'))
|
||||
{
|
||||
|
||||
// quelques donn<6E>es
|
||||
$address = "245 N 50th";
|
||||
$address = '245 N 50th';
|
||||
$db_data = array(
|
||||
"Ville" => "Lincoln",
|
||||
"Pays" => "Nebraska",
|
||||
"Code postal" = > "68502"
|
||||
'Ville' => 'Lincoln',
|
||||
'Pays' => 'Nebraska',
|
||||
'Code postal' = > '68502'
|
||||
);
|
||||
|
||||
$smarty->assign("Nom","Fred");
|
||||
$smarty->assign("Adresse",$address);
|
||||
$smarty->assign('Nom','Fred');
|
||||
$smarty->assign('Adresse',$address);
|
||||
$smarty->assign($db_data);
|
||||
|
||||
}
|
||||
|
||||
// r<>cup<75>re le r<>sultat
|
||||
$output = $smarty->fetch("index.tpl");
|
||||
$output = $smarty->fetch('index.tpl');
|
||||
|
||||
// fait quelque chose avec $output ici
|
||||
|
||||
@@ -64,8 +68,66 @@ echo $output;
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Voir aussi
|
||||
<example>
|
||||
<title>Utilisation de fetch() pour envoyer un email</title>
|
||||
<para>
|
||||
Le template email_body.tpl
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
Cher {$contact.name},
|
||||
|
||||
Bienvenu et merci d'<27>tre devenu membre de notre groupe d'utilisateur,
|
||||
|
||||
Cliquez sur le lien ci-dessous pour vous identifier avec votre nom d'utilisateur '{$contact.login_id}'
|
||||
et vous pourrez utiliser nos forums.
|
||||
|
||||
http://{$smarty.server.SERVER_NAME}/index.php?page=login
|
||||
|
||||
Liste principale
|
||||
Quelques groupes d'utilisateurs
|
||||
|
||||
{include file="email_disclaimer.tpl"}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Le template email_disclaimer.tpl qui utilise le modificateur
|
||||
<link linkend="language.function.textformat">{textformat}</link>.
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{textformat wrap=40}
|
||||
Unless you are named "{$contact.name}", you may read only the "odd numbered
|
||||
words" (every other word beginning with the first) of the message above. If you have
|
||||
violated that, then you hereby owe the sender 10 GBP for each even
|
||||
numbered word you have read
|
||||
{/textformat}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
et le script PHP utilisant la fonction PHP
|
||||
<ulink url="&url.php-manual;function.mail">mail()</ulink>
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// R<>cup<75>ration du contact depuis une base de donn<6E>es eg utilisation de pear ou adodb
|
||||
$query = 'select name, email, login_id from contacts where contact_id='.$contact_id;
|
||||
$contact = $db->getRow($sql);
|
||||
$smarty->assign('contact', $contact);
|
||||
|
||||
mail($contact['email'], 'Subject', $smarty->fetch('email_body.tpl'));
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
Voir aussi
|
||||
<link linkend="language.function.fetch">{fetch}</link>
|
||||
<link linkend="api.display">display()</link>,
|
||||
<link linkend="language.function.eval">{eval}</link> et
|
||||
|
||||
Reference in New Issue
Block a user