Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Variable dynamique

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
guyguy333
Smarty n00b


Joined: 15 Feb 2009
Posts: 1

PostPosted: Sun Feb 15, 2009 4:38 pm    Post subject: Variable dynamique Reply with quote

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) :
Code:

{$MESSAGE}


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 :
Code:
{{$MESSAGE}}


Merci
Back to top
View user's profile Send private message
Yaninho
Smarty Rookie


Joined: 11 Mar 2009
Posts: 12

PostPosted: Thu Mar 12, 2009 8:26 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP