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

Probleme pour afficher certaines variables

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


Joined: 30 Apr 2008
Posts: 2

PostPosted: Wed Apr 30, 2008 10:53 pm    Post subject: Probleme pour afficher certaines variables Reply with quote

Bonjour,

Je suis actuellement en train de developper un site perso.
J'utilise smarty depuis peu (bon ok 3 mois en fait).

Jai donc un probleme : je souhaiterais afficher la liste des membre de mon site, pour cela j'ai :

---- list_member.php (qui genere un tableau de mes membres)----
Code:
<?php
require_once('../libs/Smarty.class.php');
include("../inc/mysql.php");
include("../inc/list_member.php");

$smarty = new Smarty();
$member_list= list_member();
$smarty->register_object('member_list', $member_list);
$smarty->assign_by_ref('member_list', $member_list);
$smarty->display('index.tpl');
?>

et le template associé est list_member.tpl
Code:
<div class="post">
   <h1>Liste des membres :</h1>
   <div class="post_body">
         <table>
         <tr>
            <th>Pseudo</th>
            <th>Rangs</th>
         </tr>
         {section name=id loop=$member_list}
         <tr>
            <td>{$member_list[id].pseudo}</td>
            <td>   
                     {if $member_list[id].rank == 0}
                        Novice
                     {elseif $member_list[id].rank == 1}
                        Membre
                     {elseif $member_list[id].rank == 2}
                        Veteran
                     {elseif $member_list[id].rank == 3}
                        Officier
                     {elseif $member_list[id].rank == 4}
                        Maitre de guilde
                     {/if}
                  </td>
                  </tr>
         {/section}
         </table>
   </div>
</div>


ensuite pour afficher mes pages et les contenu j''ai :
---- index.php a la racine de mon serveur ----
Code:
<?php
session_start();

//Initialisation smarty
require_once('libs/Smarty.class.php');

//Nouvelle instance Smarty
$smarty = new Smarty();

//chooser
require ('inc/chooser.php');

//variables de sessions
if (isset($_SESSION))
   $smarty->assign('session', $_SESSION);

//affichage
$smarty->display('index.tpl');
?>


et pour mon index.tpl il contient toute la structure de ma page,
le bloc d'information que l'utilisateur veut utiliser est dans $content
Code:
<div id="middle_column">
            {include file=$content}
           </div>


et la selection de ce bloc se fait dans chooser.php :
Code:
<?php

$action = array("accueil" => "accueil",
            "inscription" => "inscription",
            "login" => "login",
            "connected" => "connected",
            "error" => "error",
            "logout" => "logout",
            "list_member" => "list_member",
            "add_perso" => "add_perso",
            "show_perso" => "show_perso",
            );

if (array_key_exists($_GET['action'], $action))
  {
    $template = $action[$_GET['action']] . '.tpl';
    $pages = '../PHP/' . $action[$_GET['action']] . '.php';
  }
 else
  {
    $template = 'news.tpl';
  }

$smarty->assign('content', $template);
$smarty->assign('error', $error);

if (file_exists($pages))
  include($pages);
?>


Le probleme est donc le suivant comment puis je afficher les information recuillit par ma fonction list_member.php pour les afficher dans mon template list_member.tpl?
La generation de la liste est bonne puisque je peux l'afficher mais malheureusement je perd tout mon css et tout ce qu'il y a autour :/

Merci de votre aide! ^^
Back to top
View user's profile Send private message
Templar
Smarty n00b


Joined: 30 Apr 2008
Posts: 2

PostPosted: Thu May 01, 2008 4:38 pm    Post subject: Resolved! Reply with quote

Bon finalement j'ai trouve d'ou provient mon problème...

Pour ceux qui aurait le même soucis avec la même configuration,
il suffit de deplacer le smarty->assign('content', $content); dans le
fichier index.php a la racine du serveur...
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