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

114 lines
3.2 KiB
XML
Raw Normal View History

2004-04-13 11:47:32 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
2006-10-14 14:54:52 +00:00
<!-- EN-Revision: 1.8 Maintainer: yannick Status: ready -->
2005-12-04 21:46:10 +00:00
2004-12-26 17:02:12 +00:00
<refentry id="api.display">
<refnamediv>
2005-12-04 21:46:10 +00:00
<refname>display()</refname>
<refpurpose>Affiche le template</refpurpose>
2004-12-26 17:02:12 +00:00
</refnamediv>
<refsect1>
2005-12-04 21:46:10 +00:00
<title>Description</title>
2004-12-26 17:02:12 +00:00
<methodsynopsis>
<type>void</type><methodname>display</methodname>
<methodparam><type>string</type><parameter>template</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
2005-12-04 21:46:10 +00:00
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter>
</methodparam>
2004-12-26 17:02:12 +00:00
</methodsynopsis>
2004-05-23 15:50:53 +00:00
<para>
2004-12-26 17:02:12 +00:00
Utilis<69>e pour afficher un template. Il faut fournir un type et un
chemin de <link
linkend="template.resources">ressource template</link>
valides. Vous pouvez passer en second param<61>tre un identifiant
2006-10-07 21:01:42 +00:00
de fichier de <parameter>$cache id</parameter>. Reportez-vous <20> la section
2004-12-26 17:02:12 +00:00
<link linkend="caching">cache</link> pour plus de renseignements.
2004-05-23 15:50:53 +00:00
</para>
2004-12-26 17:02:12 +00:00
&parameter.compileid;
2004-05-23 15:50:53 +00:00
<example>
2005-12-04 21:46:10 +00:00
<title>Exemple avec display()</title>
2004-12-26 17:02:12 +00:00
<programlisting role="php">
<![CDATA[
<?php
2006-10-07 21:01:42 +00:00
include(SMARTY_DIR.'Smarty.class.php');
$smarty = new Smarty();
2004-04-13 11:47:32 +00:00
$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
2006-10-07 21:01:42 +00:00
if(!$smarty->is_cached('index.tpl')) {
2004-04-13 11:47:32 +00:00
// quelques donn<6E>es
2006-10-14 14:54:52 +00:00
$address = '245 N 50th';
2004-04-13 11:47:32 +00:00
$db_data = array(
2006-10-14 14:54:52 +00:00
'Ville' => 'Lincoln',
'Pays' => 'Nebraska',
'Code postal' = > '68502'
2004-12-26 17:02:12 +00:00
);
2004-04-13 11:47:32 +00:00
2006-10-14 14:54:52 +00:00
$smarty->assign('Nom','Fred');
$smarty->assign('Adresse',$address);
2004-04-13 11:47:32 +00:00
$smarty->assign($db_data);
}
2005-05-09 16:45:23 +00:00
// affichage
2006-10-07 21:01:42 +00:00
$smarty->display('index.tpl');
2004-12-26 17:02:12 +00:00
?>
]]>
</programlisting>
2004-05-23 15:50:53 +00:00
</example>
<para>
Utilisez la syntaxe des <link
linkend="template.resources">ressources templates</link>
pour afficher des fichiers en-dehors du r<>pertoire
2006-10-07 21:01:42 +00:00
<link linkend="variable.template.dir"><parameter>$template_dir</parameter></link>.
2004-05-23 15:50:53 +00:00
</para>
<example>
2004-12-26 17:02:12 +00:00
<title>Exemples de fonction d'affichage de ressources templates</title>
<programlisting role="php">
<![CDATA[
<?php
2004-04-13 11:47:32 +00:00
// chemin absolu
2005-12-04 21:46:10 +00:00
$smarty->display('/usr/local/include/templates/header.tpl');
2004-04-13 11:47:32 +00:00
2004-12-26 17:02:12 +00:00
// chemin absolu (m<>m chose)
2005-12-04 21:46:10 +00:00
$smarty->display('file:/usr/local/include/templates/header.tpl');
2004-04-13 11:47:32 +00:00
// chemin absolu Windows (on DOIT utiliser le pr<70>fixe "file:")
2005-12-04 21:46:10 +00:00
$smarty->display('file:C:/www/pub/templates/header.tpl');
2004-04-13 11:47:32 +00:00
2004-12-26 17:02:12 +00:00
// inclue <20> partir de la ressource template nomm<6D>e "db"
2005-12-04 21:46:10 +00:00
$smarty->display('db:header.tpl');
2004-12-26 17:02:12 +00:00
?>
]]>
</programlisting>
2004-05-23 15:50:53 +00:00
</example>
2005-05-09 16:45:23 +00:00
<para>
Voir aussi
2006-10-07 21:01:42 +00:00
<link linkend="api.fetch"><varname>fetch()</varname></link> et
<link linkend="api.template.exists"><varname>template_exists()</varname></link>.
2005-05-09 16:45:23 +00:00
</para>
2004-12-26 17:02:12 +00:00
</refsect1>
</refentry>
2005-05-25 16:49:34 +00:00
2004-05-23 15:50:53 +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
2005-05-25 16:49:34 +00:00
-->