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

tableau d'objets en variable globale

 
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
sebpern
Smarty n00b


Joined: 20 Nov 2008
Posts: 4

PostPosted: Thu Nov 20, 2008 9:47 am    Post subject: tableau d'objets en variable globale Reply with quote

bonjour,

dans mon index.php

Code:
<?php
include('rallye.class.php');
require('Include/setup.php');
$smarty = new Smarty_TP_SMARTY();
$smarty->debugging = true;
$smarty->caching = false ;

$smarty->assign('header_text','TP SMARTY');
if ($_GET["action"]=="ajoutRallye")
{
include('pagePHP/ajoutRallye.php');
}
if ($_GET["action"]=="voirRallye")
{
include('pagePHP/voirRallye.php');
}
$smarty->display('index.tpl');
?>


mon index.tpl
Code:
<html>
 <head>
  <title>{$title}</title>
 </head>
 <body>

{include file="header.tpl"}
<div id="main" style="background-color:#6699cc;">
   {include file="$lien"|default:"accueil.tpl"}
</div>
<div>
 <a href="index.php?action=ajoutRallye">Ajout Rallye</a>
<a href="index.php?action=voirRallye">Voir rallye</a>
</div>
</body>
</html>


comment puis instancier un tableau dans ma page index.php, afin que je puisse ajouter un élément dans ce tableau dans la page ajoutRallye.php

1ère idée :
dans index .php
Code:
// si le tableau existe pas je le crée
if (!'isset($lesRallyes))
{
$lesRallyes=array();
}


et dans ajoutRallye.php
Code:
$unRallye = new rallye("jk",2);
array_push($lesRallyes,$unRallye);


mais apres cet echec me suis dit il faut utiliser les variables de templates
donc ds index.php
Code:
//count($smarty->get_template_vars('lesRallyes')
$lesRallyes=array();
$smarty->append('lesRallyes',$unRallye);


Code:
$unRallye = new rallye("jk",2);
$smarty->append($lesRallyes,$unRallye);


mais qd je redirige sur la page index apres l'ajout perd mon rallye ajouté
je crois à cause : $smarty = new Smarty_TP_SMARTY();
qui est en tete de la la page index.php
je voudrais l'empecher de refaire ce new avec isset sur $smarty
mais ne marche pas
help
merci
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