Bonjour à tous,
je tien à m'excuser si je me suis tromper d'endroit pour poster ce post, je suis un peu perdu avec tous les forum.
Bref, je suis entrain de créé un site web (sans blague) avec Smarty.
Le soucis, c'est que j'ai un menu, composé de différents bloque qui sont affiché ou pas selon la page.
Le menu est composé comme suite:
- section1 (définni selon la page, permet de choisir les block
-section 2
- block1
- lien 1
- url
- texte- block 2
- lien 2
- url
- texte
-lien 3
-url
-texte
-block 3....
-lien 4
-url
-texte
Le soucis, c'est que avec smarty, j'ai un tableau assé compliquer!
Et comme la liste n'est pas complète, je vais me perdre à cout sûr!
Ici avec smarty j'y suis arrivé comme suite:
Et le template qui va avec:
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 <?php switch($MySection[1]) { // Audio case 'audio' : $MTitre = array( $M['accueil'], 'Episodes', 'Personnages' ); break; // Jeu case 'jeu' : $MTitre = array(); break; // Forum case 'forum' : $MTitre = array(); break; // Default / Accueil / Histoire default: $MTitre = array( 'Programmation de Mendrock', $M['accueil'], 'Test'); break; } $smarty->assign('MenuTitre',$MTitre); unset($MySection); unset($jsFMTitreile); ################################ ### Nom des liens switch($SelectMenu) { // Audio case 'audio' : $MName = array( array( $M['accueil'], $M['photos'] ), array( $M['accueil'], $M['photos'] ), array( $M['accueil'], $M['photos'] ) ); break; // Jeu case 'jeu' : $MName = array(); break; // Forum case 'forum' : $MName = array(); break; // Default / Accueil / Histoire default: $MName = array( array( 'Balises', 'infos site'), array( $M['accueil'], $M['photos'], $M['livreOr'], $M['aideMendrock'], $M['merci'], $M['dedierJoe'], $M['download'] ), array( $M['accueil'], $M['photos'], $M['livreOr'] ) ); break; } $smarty->assign('MenuNom', $MName); unset($MName); ################################ ### Lien des liens switch($SelectMenu) { // Audio case 'audio' : $MLink = array( array( '?page=indexAudio', '?page=audio' ), array( '?page=indexAudio', '?page=audio' ), array( '?page=indexAudio', '?page=audio' ) ); break; // Jeu case 'jeu' : $MLink = array(); break; // Forum case 'forum' : $MLink = array(); break; // Default / Accueil / Histoire default: $MLink = array( array('?page=balise', '?page=infoCodagePhpPourSeb'), array( '?page=indexAccueil', '?page=photos', '?page=accueil', '?page=accueil', '?page=accueil', '?page=accueil', '?page=accueil' ), array( '?page=indexAccueil', '?page=accueil', '?page=accueil' ) ); break; } $smarty->assign('MenuLink', $MLink); unset($SelectMenu); unset($MLink); $smarty->assign('linktop','<a href="' .URLlast. '#top">Top</a>'); ?>
J'ai déjà essayé avec un tableau simple (car ici il y en a deux) mais je n'yu suis pas arriver.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 {section name=titre loop=$MenuTitre} <div class="menuBlock"> <div class="titreMenu">{$MenuTitre[titre]}</div> <ul> {section name=nom loop=$MenuNom[titre]} <a href="{$MenuLink[titre][nom]}"><li>{$MenuNom[titre][nom]}</li></a> {/section} </ul> </div> {/section}
J'ai également pensé à un menu fait à partir de xml, mais alors je n'arrive pas à utiliser les variables de langue.
Par ailleur, j'ai aussi essayer en POO, mais déjà dans l'édition des class je me plante pour dire que un lien appartient à un block.
Pouvez vous m'aider?
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 <?php class lien { protected $url = ""; protected $texte = ""; function __construct($url, $texte){ $this->url = $url; $this->texte = $texte; } function getUrl(){ return $this->url; } function setUrl($NewUrl){ $this->url = $NewUrl; } function getTexte(){ return $this->Texte; } function setTexte($NewTexte){ $this->texte = $NewTexte; } } class block { protected $titre = ""; function __construct($titre){ $this->titre = $titre; $this->liens = new ArrayObject(); } function getTitre(){ return $this->titre; } function setTitre($newTitre){ $this->titre = $newTitre; } function addLink($url){ $this->liens->offsetSet(url, $url->getUrl()); $this->liens->offsetSet(texte, $url->getTexte()); } function getLink(){ return $this->liens; } } class section { protected $titre = ""; function __construct($titre){ $this->titre = $titre; $this->block = new ArrayObject(); } function getTitre(){ return $this->titre; } function setTitre($newTitre){ $this->titre = $newTitre; } function addBlock($block){ $this->block->offsetSet(titre, $block->getTitre()); $this->block->offsetSet(liens, $block->getLink()); } function getBlock(){ return $this->block; } } ?>
(A choisir je prefere utiliser la poo, mais toutes les bonnes méthode sont bonne...)
Merci d'avance![]()
Partager