|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
guyguy333 Smarty n00b
Joined: 15 Feb 2009 Posts: 1
|
Posted: Sun Feb 15, 2009 4:38 pm Post subject: Variable dynamique |
|
|
Bonjour,
j'aurais aimé savoir comment afficher une variable dynamique avec smarty.
Exemple de code que je voudrais faire :
Dans le fichier php
Code: | <?php
$MESSAGE = '#error#';
$template->assign('MESSAGE', $MESSAGE );
?> |
Dans le template (tpl) :
Je ne veux pas afficher #error# mais sa valeur que j'ai mis dans un fichier de config. Ca serait un truc comme ca je pense, mais ca marche pas :
Merci |
|
Back to top |
|
Yaninho Smarty Rookie
Joined: 11 Mar 2009 Posts: 12
|
Posted: Thu Mar 12, 2009 8:26 am Post subject: |
|
|
Bonjour,
Pour résoudre ton problème, il ne faut pas en fait que tu utilise ton fichier comme ca.
Un exemple étant beaucoup plus parlant que des mots :
Fichier index.php:
Code: | <?php
require 'C:/Program Files/EasyPHP1-8/php/Smarty/libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->compile_check = true;
//$smarty->debugging = true;
$smarty->display('index.tpl');
?>
|
Fichier index.tpl:
Code: | {config_load file=test.conf section="setup"}
{include file="header.tpl" title=foo}
{#error#}
{include file="footer.tpl"} |
Fichier test.conf:
Code: | title = Welcome to Smarty!
cutoff_size = 40
[setup]
bold = true
error = 'yo' |
Resultat (HTML):
Code: |
<html>
<head>
<title>foo - </title>
</head>
<body>
yo
</body>
</html> |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|