Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > Templates > Smarty
Smarty Forum d'entraide sur le moteur de templates Smarty. Avant de poster -> FAQ Smarty et Cours Smarty
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 25/09/2008, 16h33   #1
Inactif
 
Inscription : septembre 2006
Messages : 101
Détails du profil
Informations forums :
Inscription : septembre 2006
Messages : 101
Points : 37
Points : 37
Par défaut Attribuer une class en fonction d'un résultat avec une variable

Bonjour,

J'ai besoin de vos lumières, j'essaie d'attribuer une class à une cellule en fonction de son résultat récupérer avec la variable qui attribue la class exemple

Code :
1
2
3
.exemple{
    background: #E6CCFF;
}
En gros si l'annonce et une annonce premium (annonce avec option payante) alors elle est surligner en violet. http://kitten13.dyndns.org/index.php

J'arrive a faire ce que je veu pour certaine cellule saut pour le titre/description et l'image.

En fait il me remplace la classe pointer comment faire pour lui attribuer la class d'origine ou sinon celle d'origine plus surligner ?

en gros voici ce que j'ai fait :

Code :
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
<table cellspacing="0" class="box2" style="clear:both;">
 
{foreach item=ad from=$ads}  
<tr onmouseout='this.className="alt";' onmouseover='this.className="class1";'>
 
 
<!-- ********************* ici probleme je narrive pas *********************************** -->
 
<td>{$ad.IMAGEYESNO}</td>
 
<td class="pointer"><a href="{$ad.LINK}" title="{$ad.TITLE|escape}">{$ad.TITLE|truncate:35:"...":true}</a><a href="{$ad.LINK}" style="text-decoration:none; color: #000; font: 13px verdana, sans-serif;" class="description">{$ad.DESCRIPTION|truncate:200:"...":true}</a></td>
 
<!-- ********************* fin *********************************** --> 	
 
<!-- ********************* ici probleme la classe et remplacer *********************************** -->
 
{if $ad.SPECIAL}<td class="exemple"><a href="{$ad.LINK}" style="text-decoration:none; color: #000; font: 13px verdana, sans-serif; display: block; font-weight:bold;">{if $e.islink}{/if}{$ad.e_2.value|commify:2}&nbsp;&nbsp;Eur</a></td>{/if}
 
{foreach item=extraval from=$ad.EXTRA_VALUES} {if $ad.SPECIAL}<td class="exemple">{$extraval|truncate:20:"...":true} </td>{/if}{/foreach} 
 
{if $ad.SPECIAL}<td class="exemple"><a href="{$ad.LINK}" style="text-decoration:none; color: #000; font: 13px verdana, sans-serif; display: block;">{$ad.REGDATE}</a></td>{/if}
 
<!-- ********************* fin *********************************** --> 
 
	</tr>
{/foreach} 
 
</table>
mon ccs :

Code :
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
.box2 {
	    margin: 5px 0px;
	    border-top: 5px solid #eeeeee;
	    background: #fff;
    }     
 
	.box2 td {
		padding: 5px 0px !important;
		border-bottom: 1px solid #E5E5EA;
 
	}
	.box2 td.category {
		background: url("../layout_images/new/folder.gif") 14px 9px no-repeat;
		padding-left: 36px !important;
	}
	.box2 tr.alt td.category {
		background: #e7ebf0 url("../layout_images/new/folder.gif") 14px 9px no-repeat;
		padding-left: 36px !important;
 
	}
	.box2 th {
        height: 23px;
		padding: 5px 14px !important;
		padding: 2px 14px;
		white-space: nowrap;
		text-align: left;
		vertical-align: middle;
	    color:#848484;
        font-size:11px;
        font-weight:bold;
        padding:5px 3px 3px;
	}
 
	.box2 th a {
		color:#848484;
        font-size:11px;
        font-weight:bold;
        padding:5px 3px 3px;
 
	}
	.box2 th a:hover {
		text-decoration: underline;
	}
	.box2 td a, #content a {
		text-decoration: underline;
		display: block;
	}
	.box2 td a strong {
		font-size: 110%;
	}
	.box2 td a:hover, .box td a:hover strong, #content a:hover {
		display: block;
	}
	.box2 tr.alt {
		background: #fff;
 
	}
	.box2 td.pointer {
		background: 14px 10px no-repeat;
		padding-left: 0px !important;
		border-bottom: 1px solid #E5E5EA;
	}
	.box2 tr.alt td.pointer {
		background: #fff 14px 10px no-repeat;
		padding-left: 0px !important;
		border-bottom: 1px solid #E5E5EA;
	}
 
	.exemple{
        background: #E6CCFF;
    }
kitten13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/09/2008, 20h03   #2
Inactif
 
Inscription : septembre 2006
Messages : 101
Détails du profil
Informations forums :
Inscription : septembre 2006
Messages : 101
Points : 37
Points : 37
j'ai trouver mon erreur je mets un exemple pour les autres

en faite il faut utiliser les conditions
Code :
1
2
3
4
5
6
7
8
9
10
11
 
 
{if $ad.SPECIAL}                                     <---- si le resultat correspond alors on affiche 
 
<td class="exemple">{mon_image}</td>     <---- ceci
 
{else}                                                     <---- ou sinon on affiche
 
<td>{mon_image}</td>                            <---- ceci 
 
{/if}
je laisse le soins à quelqu'un d'expliquer la méthode car je suis pas bon prof

sinon lire ce tutoriel sur smarty il ma beaucoup aider

http://php.developpez.com/faq/?page=...rty-conditions
kitten13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 06h12.


 
 
 
 
Partenaires

Hébergement Web