Files
smarty/docs/fr/programmers/api-functions/api-fetch.xml

94 lines
2.4 KiB
XML
Raw Normal View History

2004-04-13 11:47:32 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
2005-05-09 16:45:23 +00:00
<!-- EN-Revision: 1.4 Maintainer: yannick Status: ready -->
2004-12-26 17:02:12 +00:00
<refentry id="api.fetch">
<refnamediv>
<refname>fetch</refname>
<refpurpose></refpurpose>
</refnamediv>
<refsect1>
<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>
</methodsynopsis>
<para>
Utilis<69>e pour renvoyer le r<>sultat du template plut<75>t que de l'afficher.
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
param<61>tre. Reportez-vous <20> la section <link linkend="caching">cache
</link> pour plus de renseignements.
</para>
&parameter.compileid;
<para>
<example>
<title>Exemple avec fetch</title>
<programlisting role="php">
<![CDATA[
<?php
2004-04-13 11:47:32 +00:00
include("Smarty.class.php");
$smarty = new Smarty;
$smarty->caching = true;
2004-12-26 17:02:12 +00:00
// ne fait un appel <20> la base de donn<6E>es que si le fichier
2004-04-13 11:47:32 +00:00
// de cache n'existe pas
if(!$smarty->is_cached("index.tpl"))
{
// quelques donn<6E>es
$address = "245 N 50th";
$db_data = array(
2004-12-26 17:02:12 +00:00
"Ville" => "Lincoln",
"Pays" => "Nebraska",
"Code postal" = > "68502"
);
2004-04-13 11:47:32 +00:00
2004-12-26 17:02:12 +00:00
$smarty->assign("Nom","Fred");
$smarty->assign("Adresse",$address);
2004-04-13 11:47:32 +00:00
$smarty->assign($db_data);
}
// r<>cup<75>re le r<>sultat
$output = $smarty->fetch("index.tpl");
2005-05-09 16:45:23 +00:00
// fait quelque chose avec $output ici
2004-04-13 11:47:32 +00:00
2004-12-26 17:02:12 +00:00
echo $output;
?>
]]>
</programlisting>
</example>
</para>
2005-05-09 16:45:23 +00:00
<para>
Voir aussi
<link linkend="api.display">display()</link> et
<link linkend="api.template.exists">template_exists</link>.
</para>
2004-12-26 17:02:12 +00:00
</refsect1>
</refentry>
2004-04-13 11:47:32 +00:00
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
2004-05-23 15:50:53 +00:00
-->