mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-28 19:01:37 +01:00
sync with EN
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.5 Maintainer: yannick Status: ready -->
|
||||
<!-- EN-Revision: 1.6 Maintainer: yannick Status: ready -->
|
||||
|
||||
<sect1 id="advanced.features.objects">
|
||||
<title>Objets</title>
|
||||
<para>
|
||||
Smarty donne l'acc<63>s aux objets PHP <20> travers les templates. Il y
|
||||
a 2 moyens d'y avoir acc<63>s. Le premier consiste <20>
|
||||
Smarty donne l'acc<63>s aux <ulink url="&url.php-manual;object">objets</ulink>
|
||||
PHP <20> travers les templates. Il y a 2 moyens d'y avoir acc<63>s. Le premier consiste <20>
|
||||
<link linkend="api.register.object">allouer les objets</link>
|
||||
au template puis de les utiliser avec une syntaxe similaire a celles
|
||||
des fonctions personnalis<69>es. Le deuxi<78>me moyen consiste <20>
|
||||
<link linkend="api.assign">assigner des objets</link>
|
||||
des <link linkend="language.custom.functions">fonctions personnalis<69>es</link>.
|
||||
Le deuxi<78>me moyen consiste <20> <link linkend="api.assign">assigner</link> des objets
|
||||
aux templates et de les utiliser comme n'importe quelle
|
||||
variable. La premi<6D>re m<>thode a une syntaxe beaucoup plus sympathique.
|
||||
Elle est aussi plus s<>curis<69>e, puisqu'un objet allou<6F> ne peut avoir acc<63>s
|
||||
qu'a certaines m<>thodes et propri<72>t<EFBFBD>s. N<>anmoins,
|
||||
qu'a certaines m<>thodes et propri<72>t<EFBFBD>s. N<>anmoins,
|
||||
<emphasis role="bold">un objet allou<6F> ne peut pas avoir de lien sur lui-m<>me
|
||||
ou <20>tre mis dans un tableau d'objet</emphasis>, etc.
|
||||
ou <20>tre mis dans un tableau d'objet</emphasis>, etc.
|
||||
Vous devez choisir la m<>thode qui correspond a vos
|
||||
besoins, mais tGchez d'utiliser la premi<6D>re m<>thode autant que possible
|
||||
afin de r<>duire la syntaxe des templates au minimum.
|
||||
@@ -64,22 +65,22 @@
|
||||
|
||||
class My_Object() {
|
||||
function meth1($params, &$smarty_obj) {
|
||||
return "this is my meth1";
|
||||
return 'Ceci est ma methode 1';
|
||||
}
|
||||
}
|
||||
|
||||
$myobj = new My_Object;
|
||||
// enregistre l'objet
|
||||
$smarty->register_object("foobar",$myobj);
|
||||
$smarty->register_object('foobar',$myobj);
|
||||
// on restreint l'acc<63>s a certaines m<>thodes et propri<72>t<EFBFBD>s en les listant
|
||||
$smarty->register_object("foobar",$myobj,array('meth1','meth2','prop1'));
|
||||
$smarty->register_object('foobar',$myobj,array('meth1','meth2','prop1'));
|
||||
// pour utiliser le format habituel de param<61>tre objet, passez le bool<6F>en = false
|
||||
$smarty->register_object("foobar",$myobj,null,false);
|
||||
$smarty->register_object('foobar',$myobj,null,false);
|
||||
|
||||
// on peut aussi assigner des objets. Assignez par r<>f<EFBFBD>rence quand c'est possible
|
||||
$smarty->assign_by_ref("myobj", $myobj);
|
||||
$smarty->assign_by_ref('myobj', $myobj);
|
||||
|
||||
$smarty->display("index.tpl");
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
|
||||
?>
|
||||
@@ -102,6 +103,11 @@ the output was {$output)
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Voir aussi
|
||||
<link linkend="api.register.object">register_object()</link> et
|
||||
<link linkend="api.assign">assign()</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
||||
Reference in New Issue
Block a user