Attribuer un identifiant aux catégories
2 participants
Forum gratuit : Le forum des forums actifs :: Entraide & Support... :: Problème avec un script, un code :: Archives des problèmes avec un code
Page 1 sur 1 • Partagez
Attribuer un identifiant aux catégories
Détails techniques
Version du forum : phpBB2
Poste occupé : Fondateur
Navigateur(s) concerné(s) : Google Chrome
Personnes concernées par le problème : Tous les utilisateurs
Lien du forum : http://forum-test-phpbb2.forumactif.org/
Description du problème
Re-bonjour !! ^^J'aurais encore besoin d'aide pour du javascript
Voilà mon souci : dans le but de mettre des images de fond dans les différentes catégories d'un forum et autres applications pratiques, j'ai réutilisé une partie d'un javascript pour catégories en onglet afin d'attribuer un identifiant à chaque catégorie, en l’occurrence les numéroter, tout simplement.
(Bon, ce n'est sûrement pas le plus beau code qui soit, mais j'étais tellement contente pour une fois d'avoir réussi à me dépatouiller toute seule !.... *déprime*).
Le code en lui même fonctionne bien, mais il y a un effet un peu embêtant auquel je n'avais pas pensé au départ : les catégories qui ne sont pas visibles pour l'utilisateur provoquent un décalage dans la numérotation !
Par exemple sur mon forum test, j'ai fait correspondre le titre de la catégorie au numéro de son identifiant. Mais comme la catégorie n°2 n'est pas visible aux invités, ces derniers se retrouvent avec la catégorie n°3 portant l'identifiant n°2, etc !
Donc voilà ma question pour résumer : y aurait-il un autre moyen d'appliquer un identifiant constant à chaque catégorie, quelques soient les affichages/permissions/etc ? =s
(et du coup au passage, est ce que ce soucis ne fausse pas également le code complet pour les catégories en onglets ? =s celui pour lequel j'avais demandé de l'aide dans ce sujet...)
- Les codes que j'ai utilisés pour identifier les catégories :
Le template index-box :- Code:
<table width="100%" border="0" cellspacing="1" cellpadding="0" align="center">
<tr>
<td valign="bottom">
<!-- BEGIN switch_user_logged_in -->
<span class="gensmall">{LAST_VISIT_DATE}<br />
{CURRENT_TIME}<br />
</span>
<!-- END switch_user_logged_in -->
<div class="nav"><a class="nav" href="{U_INDEX}">{L_INDEX}</a>{NAV_CAT_DESC}</div>
</td>
<td class="gensmall" align="right" valign="bottom">
<!-- BEGIN switch_user_logged_in -->
<a class="gensmall" href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a><br />
<a class="gensmall" href="{U_SEARCH_SELF}">{L_SEARCH_SELF}</a><br />
<!-- END switch_user_logged_in -->
<a class="gensmall" href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a>
</td>
</tr>
</table>
<!-- BEGIN catrow --><!-- BEGIN tablehead -->
<script type="text/javascript">
<!--
capture_cat();
//-->
</script>
<tr>
<th colspan="{catrow.tablehead.INC_SPAN}" nowrap="nowrap" width="100%" class="secondarytitle"> {catrow.tablehead.L_FORUM} </th>
<th nowrap="nowrap" width="50">{L_TOPICS}</th>
<th nowrap="nowrap" width="50">{L_POSTS}</th>
<th nowrap="nowrap" width="150"><div style="width:150px;">{L_LASTPOST}</div></th>
</tr>
<!-- END tablehead -->
<!-- BEGIN cathead -->
<tr>
<!-- BEGIN inc -->
<td class="{catrow.cathead.inc.INC_CLASS}" width="46"><img src="{SPACER}" height="0" width="46" /></td>
<!-- END inc -->
<td class="{catrow.cathead.CLASS_CAT}" colspan="{catrow.cathead.INC_SPAN}" width="100%">
<h{catrow.cathead.LEVEL} class="hierarchy">
<span class="cattitle">
<a class="cattitle" title="{catrow.cathead.CAT_DESC}" href="{catrow.cathead.U_VIEWCAT}">{catrow.cathead.CAT_TITLE}</a>
</span>
</h{catrow.cathead.LEVEL}>
</td>
<td class="{catrow.cathead.CLASS_ROWPIC}" colspan="3" align="right"> </td>
</tr>
<!-- END cathead -->
<!-- BEGIN forumrow -->
<tr>
<!-- BEGIN inc -->
<td class="{catrow.forumrow.inc.INC_CLASS}" width="46"><img src="{SPACER}" height="0" width="46" alt="." /></td>
<!-- END inc -->
<td class="{catrow.forumrow.INC_CLASS}" align="center" valign="middle">
<img title="{catrow.forumrow.L_FORUM_FOLDER_ALT}" src="{catrow.forumrow.FORUM_FOLDER_IMG}" alt="{catrow.forumrow.L_FORUM_FOLDER_ALT}" />
</td>
<td class="row1 over" colspan="{catrow.forumrow.INC_SPAN}" valign="top" width="100%" height="50">
<h{catrow.forumrow.LEVEL} class="hierarchy">
<span class="forumlink">
<a class="forumlink" href="{catrow.forumrow.U_VIEWFORUM}">{catrow.forumrow.FORUM_NAME}</a><br />
</span>
</h{catrow.forumrow.LEVEL}>
<span class="genmed">{catrow.forumrow.FORUM_DESC}</span>
<span class="gensmall">
<!-- BEGIN switch_moderators_links -->
{catrow.forumrow.switch_moderators_links.L_MODERATOR}{catrow.forumrow.switch_moderators_links.MODERATORS}
<!-- END switch_moderators_links -->
{catrow.forumrow.L_LINKS}{catrow.forumrow.LINKS}
</span>
</td>
<td class="row3" align="center" valign="middle" height="50">
<span class="gensmall">{catrow.forumrow.TOPICS}</span>
</td>
<td class="row2" align="center" valign="middle" height="50">
<span class="gensmall">{catrow.forumrow.POSTS}</span>
</td>
<td class="row3 over" align="center" valign="middle" height="50">
<!-- BEGIN avatar -->
<div style="width: 200px;"></div>
<span class="lastpost-avatar">{catrow.forumrow.avatar.LAST_POST_AVATAR}</span>
<!-- END avatar -->
<span class="gensmall">{catrow.forumrow.LAST_POST}</span>
</td>
</tr>
<!-- END forumrow -->
<!-- BEGIN catfoot -->
<tr>
<!-- BEGIN inc -->
<td class="{catrow.catfoot.inc.INC_CLASS}" width="46"><img src="{SPACER}" height="0" width="46" /></td>
<!-- END inc -->
<td class="spaceRow" colspan="{catrow.catfoot.INC_SPAN}" height="1"><img src="{SPACER}" alt="" height="1" width="1" /></td>
</tr>
<!-- END catfoot -->
<!-- BEGIN tablefoot -->
</table><img src="{SPACER}" alt="" height="5" width="1" /><!-- END tablefoot --><!-- END catrow -->
Le javascript associé :- Code:
var compteur_cat = 0;
var nom_cat = new Array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15');
function capture_cat()
{document.write('<table class="categorie forumline" width="100%" border="0" cellspacing="1" cellpadding="0" id="cat' + nom_cat[compteur_cat] + '">');
compteur_cat++;
}
Merci d'avance encore une fois !! o/
Dernière édition par MlleAlys le Jeu 12 Mar 2015 - 12:14, édité 2 fois (Raison : quelques précisions supplémentaires et fautes d'orthographe et de frappe en moins ! xD)
MlleAlys- Membre actif
- Messages : 5800
Inscrit(e) le : 12/09/2012
Re: Attribuer un identifiant aux catégories
Bonjour ^^
J'ai une solution peut-être pas très élégante, mais qui devrait fonctionner.
On passe par la description du premier forum visible et on y ajoute un marqueur
Ensuite, niveau javascript plus qu'à rajouter quelque chose comme cela :
J'ai une solution peut-être pas très élégante, mais qui devrait fonctionner.
On passe par la description du premier forum visible et on y ajoute un marqueur
- Code:
<span id="forum_1_1"><span>
Ensuite, niveau javascript plus qu'à rajouter quelque chose comme cela :
- Code:
$(function() {
$('#forum_1_1').closest('table').addClass('categ01');
});
Re: Attribuer un identifiant aux catégories
Salut MlleAlys et Neptune-,
il y a une autre solution en prenant le nom de la catégorie comme ceci:
Pour la première catégorie le script sera donc:
a++
il y a une autre solution en prenant le nom de la catégorie comme ceci:
- Code:
$(function(){
$('th.secondarytitle h2:contains("NOM DE LA CATEGORIE")').closest('.forumline').attr('id','cat1');
});
Pour la première catégorie le script sera donc:
- Code:
$(function(){
$('th.secondarytitle h2:contains("Catégorie 1")').closest('.forumline').attr('id','cat1');
});
a++
Invité- Invité
Re: Attribuer un identifiant aux catégories
Bonjour, merci de vos réponses !!!
Je comprends mieux le code de Milouze14, ça correspond exactement à ce que je veux, et il fonctionne très bien (jusqu'à ma prochaine demande d'aide ? xD) donc je vais prendre celui là, mais merci aussi Naptune- !
Je passe en résolu ! :thanks:
Je comprends mieux le code de Milouze14, ça correspond exactement à ce que je veux, et il fonctionne très bien (jusqu'à ma prochaine demande d'aide ? xD) donc je vais prendre celui là, mais merci aussi Naptune- !
Je passe en résolu ! :thanks:
MlleAlys- Membre actif
- Messages : 5800
Inscrit(e) le : 12/09/2012
Sujets similaires
» attribuer 2 rangs c'est possible?
» Attribuer/réinitialiser les n° des utilisateurs
» Attribuer une couleur de police
» Attribuer un id à chaque catégorie ?
» Attribuer une image à un groupe
» Attribuer/réinitialiser les n° des utilisateurs
» Attribuer une couleur de police
» Attribuer un id à chaque catégorie ?
» Attribuer une image à un groupe
Forum gratuit : Le forum des forums actifs :: Entraide & Support... :: Problème avec un script, un code :: Archives des problèmes avec un code
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum