Bonjour,
j'ai récupéré une application où le développeur a utilisé XTemplate (quel choix bizarre, la documentation est vraiment pas top..). Le template nommé Bienvenue.xtpl.html (c'est normal que ça finisse par html ? ) est de cette forme :
et le fichier bienvenue.php ressemble à ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 <!-- BEGIN: main --> <link href="../cbstyles.css" rel="stylesheet" type="text/css"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>accès aux fonctions</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <table width="600" align="center" border="0" cellpadding="0" cellspacing="0"> <!-- BEGIN: FONCTION --> <tr><td> </td></tr> <tr> <th width="22" scope="col"></th> <th colspan="2" align="left" scope="col">{LIBELLE_FONCTION}</th> </tr> <!-- BEGIN: SOUS_FONCTION --> <tr> <td> </td> <!-- BEGIN: GAUCHE --> <td width="350" align="left"><a href="{LIEN_G}">{LIBELLE_SOUS_FONCTION_GAUCHE}</a> </td> <!-- END: GAUCHE --> <!-- BEGIN: DROITE --> <td width="350" align="left"><a href="{LIEN_D}">{LIBELLE_SOUS_FONCTION_DROITE}</a> </td> <!-- END: DROITE --> </tr> <!-- END: SOUS_FONCTION --> <!-- END: FONCTION --> </table> <!-- BEGIN: PIED_PAGE --> <p> </p> <p>{PIED} <!-- END: PIED_PAGE --> <p> </p> </body> </html> <!-- END: main -->
et donc avec ce code, j'ai sans arrêt des erreurs comme "undefined index main.FONCTION.SOUS_FONCTION.DROITE", quelqu'un sait ce qui cloche ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 $xtpl = new XTemplate("Bienvenue.xtpl.html"); $reqSfct = "select * from sous_fonction where id_fonction = 4 order by libelle_sous_fonction"; $resreqSfct = mysql_query($reqSfct); $nbsfct = mysql_num_rows($resreqSfct); $ind = 0; while($linesfct=mysql_fetch_assoc($resreqSfct)) { $nbsfct = $nbsfct -1; $url = $linesfct['url']; $lbelle_sous_fonction =$linesfct['libelle_sous_fonction']; if ($ind == 0) { $ind =1; $xtpl -> assign('LIEN_G',"$url"); $xtpl -> assign("LIBELLE_SOUS_FONCTION_GAUCHE","$lbelle_sous_fonction"); $xtpl -> parse("main.FONCTION.SOUS_FONCTION.GAUCHE"); } else { $ind =0; $xtpl->assign('LIEN_D',"$url"); $xtpl -> assign("LIBELLE_SOUS_FONCTION_DROITE","$lbelle_sous_fonction"); $xtpl -> parse("main.FONCTION.SOUS_FONCTION.DROITE"); } if($ind == 0 || $nbsfct == 0) { $xtpl->parse("main.FONCTION.SOUS_FONCTION"); } }// fin du while sous_fonctions $xtpl -> parse("main.FONCTION");
Après une recherche sur mon moteur de recherche préféré j'ai vu que certains parlaient d'un problème avec Windows. Mais j'ai récupéré les sources du 1er exemple sur le site officiel de XTemplate et je n'ai aucune erreur..
une dernière chose : le développeur a aussi eu la bonne idée de renommer le fichier XTemplate.class.php en xtpl.php et au début du fichier bienvenue.php, il a mis require_once('../xtpl.php');
Partager