Couleur de groupe en fond de pseudo

2 participants

Voir le sujet précédent Voir le sujet suivant Aller en bas

Résolu Couleur de groupe en fond de pseudo

Message par Aspen_Hayes Lun 25 Nov 2024 - 14:31

Détails techniques


Version du forum : phpBB2
Poste occupé : Fondateur
Navigateur(s) concerné(s) : Google Chrome
Capture d'écran du problème :
Voir l'image:

Personnes concernées par le problème : Tous les utilisateurs
Problème apparu depuis : 25/11
Lien du forum : (lien masqué, vous devez poster pour le voir)

Description du problème

Bonjour,

C'est encore moi Assomé
Je vais essayer d'expliquer ma requête le plus précisément possible.
J'aimerai que la bande bleu qui s'affiche en fond du pseudo dans le profil (profil qu'on voit dans les sujets lorsqu'on poste un message) prenne automatiquement la couleur du groupe du membre (plutôt que ce soit le pseudo qui soit coloré).
J'ai essayé de suivre ce tutoriel: https://blankthemerpg.forumactif.com/t133-utiliser-la-couleur-du-groupe-sur-le-profil ; mais j'avoue que je ne suis pas forcément très à l'aise avec le JS et à chaque fois que je manipule, je fais pire que mieux.

Je joins le CSS qui concerne le profil ainsi que le template concerné.

TEMPLATE:

CSS:

Merci d'avance Affirmatif
Aspen_Hayes

Aspen_Hayes
Nouveau membre

Messages : 26
Inscrit(e) le : 24/05/2023

https://monbordelnonorganise.forumactif.com/
Aspen_Hayes a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Couleur de groupe en fond de pseudo

Message par Milouze14 Lun 25 Nov 2024 - 17:40

Hello Aspen_Hayes,
je viens de déposer ce script directement dans le template:
Le script veut dire, je cherche dans la class as_profil_content, la couleur du span ayant un style (couleur du groupe) dans la class as_pseudo.
Si je trouve une couleur alors je donne une couleur de fond à la class as_pseudo Wink .

Code:
<script>
  $(function(){
$('.as_profil_content').each(function(){
var color=$(this).find('.as_pseudo span[style]').css('color');
if(color)
{
$(this).find('.as_pseudo').css('background',color);
}
});});
</script>

Édites ton template et supprimes tout le contenu et dépose celui-ci (juste le script en plus Wink ) :

Code:
<script type="text/javascript">
//<![CDATA[
var multiquote_img_off = '{JS_MULTIQUOTE_IMG_OFF}', multiquote_img_on = '{JS_MULTIQUOTE_IMG_ON}', _atr = '{JS_DIR}addthis/', _ati = '{PATH_IMG_FA}addthis/'{ADDTHIS_LANG}, addthis_localize = { share_caption: "{L_SHARE_CAPTION}", email: "{L_EMAIL}", email_caption: "{L_EMAIL_CAPTION}", favorites: "{L_SHARE_BOOKMARKS}", print: "{L_PRINT}", more: "{L_MORE}" };
$(function(){
    if(typeof(_atc) == "undefined") {
        _atc = {  };
    }
});

var hiddenMsgLabel = { visible:'{JS_HIDE_HIDDEN_MESSAGE}', hidden:'{JS_SHOW_HIDDEN_MESSAGE}' };
showHiddenMessage = function(id)
{
    try
    {
        var regId = parseInt(id, 10);
        if( isNaN(regId) ) { regId = 0; }
      
        if( regId > 0)
        {
            $('.post--' + id).toggle(0, function()
         {
            if( $(this).is(":visible") )
            {
               $('#hidden-title--' + id).html(hiddenMsgLabel.visible);
            }
            else
            {
               $('#hidden-title--' + id).html(hiddenMsgLabel.hidden);
            }
         });
        }
    }
    catch(e) { }
  
   return false;
};

//]]>
</script>
<script>
  $(function(){
$('.as_profil_content').each(function(){
var color=$(this).find('.as_pseudo span[style]').css('color');
if(color)
{
$(this).find('.as_pseudo').css('background',color);
}
});});
</script>
<div class="nouveau_repondre">
     <!-- BEGIN switch_user_authpost -->
      <a href="{U_POST_NEW_TOPIC}" rel="nofollow">
                     <img src="{POST_IMG}" id="{POST_IMG_ID}one" alt="{L_POST_NEW_TOPIC}" align="middle" border="0" />
        </a>
     <!-- END switch_user_authpost -->
        
     <!-- BEGIN switch_user_authreply -->
      <a href="{U_POST_REPLY_TOPIC}">
                     <img src="{REPLY_IMG}" id="i_reply" alt="{L_POST_REPLY_TOPIC}" align="middle" border="0" />
        </a>
   <!-- END switch_user_authreply -->
</div>

<div class="fil_ariane">
     <a class="nav" href="{U_INDEX}">
             <span>
                     {L_INDEX}
             </span>
     </a>
              
     <!--{NAV_SEP}<a class="nav" href="{U_ALBUM}"><span>{L_ALBUM}</span></a>-->
        {NAV_CAT_DESC_SECOND}
 
     <div class="pagination_affichage_sujet">
             <!-- BEGIN topicpagination -->
         {PAGINATION}
      <!-- END topicpagination -->
     </div>
</div>

<table class="affichage_sujets" width="100%" border="0" cellspacing="1" cellpadding="0" >
   <tr>
      <td class="header_sujet" colspan="2" height="28">
         <h1>
                             {TOPIC_TITLE}
                     </h1>
      </td>
   </tr>
  
   {POLL_DISPLAY}
 
  
   <!-- BEGIN postrow -->
   <!-- BEGIN hidden -->
   <tr>
      <td class="postdetails {postrow.hidden.ROW_CLASS}" colspan="2" align="center">{postrow.hidden.MESSAGE}</td>
   </tr>
   <!-- END hidden -->
   <!-- BEGIN displayed -->
     <tr><td colspan="2"><div class="as_infos">
                                 {L_POST_SUBJECT}: {postrow.displayed.POST_SUBJECT}   {postrow.displayed.POST_DATE}              
          </div></td></tr>
 
   <tr class="post post--{postrow.displayed.U_POST_ID}" id="p{postrow.displayed.U_POST_ID}" style="{postrow.displayed.DISPLAYABLE_STATE}">
      
      <td {postrow.displayed.THANK_BGCOLOR} valign="top" class="as_profil">
         <div class="as_profil_content">
                             <a name="{postrow.displayed.U_POST_ID}" style="position: relative; top: -30px; width: 1px;" id="{postrow.displayed.U_POST_ID}"></a>
                        <div class="as_pseudo">
                                 {postrow.displayed.POSTER_NAME}
                          </div><br/>
                
                        <div class="as_avatar">
                                {postrow.displayed.POSTER_AVATAR}
                        </div>      
                    
                        <div class="contact_perso">{postrow.displayed.PROFILE_IMG}{postrow.displayed.PM_IMG}{postrow.displayed.ONLINE_IMG}</div><hr>
            <div {postrow.displayed.AWARDS_SHOW} class="dd_award {postrow.displayed.PROFILE_POSITION}">{postrow.displayed.AWARDS}</div>
            <div class="award_more"></div>
            <br>
            <div class="SCROLLPROFIL"><div class="profil_mess"><!-- BEGIN profile_field -->
        {postrow.displayed.profile_field.LABEL} {postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}
  <!-- END profile_field --></div>
              {postrow.displayed.POSTER_RPG}<br /></div><br />
                                  <div class="contact_perso">
<!-- BEGIN contact_field -->
  <span>{postrow.displayed.contact_field.CONTENT}</span>
                                    <!-- END contact_field --></div>
          <br />
<div class="as_options">
                             {postrow.displayed.QUOTE_IMG} {postrow.displayed.EDIT_IMG} {postrow.displayed.DELETE_IMG}
                     </div>
      </td>
        
        
      <td {postrow.displayed.THANK_BGCOLOR} valign="top" width="100%" height="28">
         <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
               <td colspan="2">
                  <!-- BEGIN switch_vote_active -->
                  <div class="vote gensmall">
                     <!-- BEGIN switch_vote -->
                     <div class="vote-button"><a href="{postrow.displayed.switch_vote_active.switch_vote.U_VOTE_PLUS}">+</a></div>
                     <!-- END switch_vote -->

                     <!-- BEGIN switch_bar -->
                     <div class="vote-bar" title="{postrow.displayed.switch_vote_active.L_VOTE_TITLE}">
                        <!-- BEGIN switch_vote_plus -->
                        <div class="vote-bar-plus" style="height:{postrow.displayed.switch_vote_active.switch_bar.switch_vote_plus.HEIGHT_PLUS}px;"></div>
                        <!-- END switch_vote_plus -->

                        <!-- BEGIN switch_vote_minus -->
                        <div class="vote-bar-minus" style="height:{postrow.displayed.switch_vote_active.switch_bar.switch_vote_minus.HEIGHT_MINUS}px;"></div>
                        <!-- END switch_vote_minus -->
                     </div>
                     <!-- END switch_bar -->

                     <!-- BEGIN switch_no_bar -->
                     <div title="{postrow.displayed.switch_vote_active.L_VOTE_TITLE}" class="vote-no-bar">----</div>
                     <!-- END switch_no_bar -->

                     <!-- BEGIN switch_vote -->
                     <div class="vote-button"><a href="{postrow.displayed.switch_vote_active.switch_vote.U_VOTE_MINUS}">-</a></div>
                     <!-- END switch_vote -->
                  </div>
                  <!-- END switch_vote_active -->

                  <div class="postbody">

                     <div class="content_message">{postrow.displayed.MESSAGE}</div>

                     <!-- BEGIN switch_attachments -->
                     <dl class="attachbox">
                        <dt>{postrow.displayed.switch_attachments.L_ATTACHMENTS}</dt>
                        <dd>
                           <!-- BEGIN switch_post_attachments -->
                           <dl class="file">
                              <dt>
                                 <img src="{postrow.displayed.switch_attachments.switch_post_attachments.U_IMG}" alt="" />

                                 <!-- BEGIN switch_dl_att -->
                                 <a class="postlink" href="{postrow.displayed.switch_attachments.switch_post_attachments.switch_dl_att.U_ATTACHMENT}">{postrow.displayed.switch_attachments.switch_post_attachments.switch_dl_att.ATTACHMENT}</a> {postrow.displayed.switch_attachments.switch_post_attachments.switch_dl_att.ATTACHMENT_DEL}
                                 <!-- END switch_dl_att -->

                                 <!-- BEGIN switch_no_dl_att -->
                                 {postrow.displayed.switch_attachments.switch_post_attachments.switch_no_dl_att.ATTACHMENT} {postrow.displayed.switch_attachments.switch_post_attachments.switch_no_dl_att.ATTACHMENT_DEL}
                                 <!-- END switch_no_dl_att -->
                              </dt>

                              <!-- BEGIN switch_no_comment -->
                              <dd>
                                 <em>{postrow.displayed.switch_attachments.switch_post_attachments.switch_no_comment.ATTACHMENT_COMMENT}</em>
                              </dd>
                              <!-- END switch_no_comment -->

                              <!-- BEGIN switch_no_dl_att -->
                              <dd>
                                 <em><strong>{postrow.displayed.switch_attachments.switch_post_attachments.switch_no_dl_att.TEXT_NO_DL}</strong></em>
                              </dd>
                              <!-- END switch_no_dl_att -->

                              <dd>({postrow.displayed.switch_attachments.switch_post_attachments.FILE_SIZE}) {postrow.displayed.switch_attachments.switch_post_attachments.NB_DL}</dd>
                           </dl>
                           <!-- END switch_post_attachments -->
                        </dd>
                     </dl>
                     <!-- END switch_attachments -->

                     <div class="clear"></div>
                     <!-- BEGIN switch_signature -->
                     <div class="signature_div">
                        {postrow.displayed.SIGNATURE}
                     </div>
                     <!-- END switch_signature -->

                  </div>
                  <span class="gensmall">{postrow.displayed.EDITED_MESSAGE}</span>
               </td>
            </tr>
         </table>
      </td>
   </tr>
   <tr class="post--{postrow.displayed.U_POST_ID}" style="{postrow.displayed.DISPLAYABLE_STATE}">
   </tr>
   <!-- BEGIN first_post_br -->
</table>

<table class="forumline" width="100%" border="0" cellspacing="1" cellpadding="0">
   <!-- END first_post_br -->
   <!-- END displayed -->
   <!-- END postrow -->
   <!-- BEGIN no_post -->
   <tr align="center">
      <td colspan="2" height="28">
         <span class="genmed">{no_post.L_NO_POST}</span>
      </td>
   </tr>
   <!-- END no_post -->
</table>




<!-- BEGIN promot_trafic -->
<!-- END promot_trafic -->

<!-- BEGIN switch_forum_rules -->
<table id="forum_rules" class="forumline" width="100%" border="0" cellspacing="0" cellpadding="0" style="margin: 1px 0px 1px 0px">
   <tbody>
      <tr>
         <td class="catBottom">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
               <tbody>
                  <tr>
                     <td valign="top">
                        <div class="cattitle"> {L_FORUM_RULES}</div>
                     </td>
                  </tr>
               </tbody>
            </table>
         </td>
      </tr>
      <tr>
         <td class="row1 clearfix">
            <table>
               <tr>
                  <!-- BEGIN switch_forum_rule_image -->
                  <td class="logo">
                     <img src="{RULE_IMG_URL}" alt="" />
                  </td>
                  <!-- END switch_forum_rule_image -->
                  <td class="rules postbody">
                     {RULE_MSG}
                  </td>
               </tr>
            </table>
         </td>
      </tr>
   </tbody>
</table>
<!-- END switch_forum_rules -->

<table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
      <td colspan="2" align="center" style="padding:0px">
         <!-- BEGIN switch_user_logged_in -->
         <a name="quickreply"></a>
         {QUICK_REPLY_FORM}<br />
         <!-- END switch_user_logged_in -->
      </td>
   </tr>
</table>

<div class="fil_ariane">
     <a class="nav" href="{U_INDEX}">
             <span>
                     {L_INDEX}
             </span>
     </a>
              
     <!--{NAV_SEP}<a class="nav" href="{U_ALBUM}"><span>{L_ALBUM}</span></a>-->
        {NAV_CAT_DESC_SECOND}
 
     <div class="pagination_affichage_sujet">
             <!-- BEGIN topicpagination -->
         {PAGINATION}
      <!-- END topicpagination -->
     </div>                  
</div>
 
<div class="nouveau_repondre">
     <!-- BEGIN switch_user_authpost -->
      <a href="{U_POST_NEW_TOPIC}" rel="nofollow">
                     <img src="{POST_IMG}" id="{POST_IMG_ID}Newtopic" alt="{L_POST_NEW_TOPIC}" align="middle" border="0" />
        </a>
     <!-- END switch_user_authpost -->
            
     <!-- BEGIN switch_user_authreply -->
      <a href="{U_POST_REPLY_TOPIC}">
                     <img src="{REPLY_IMG}" alt="{L_POST_REPLY_TOPIC}" align="middle" border="0" />
        </a>
   <!-- END switch_user_authreply -->
</div>
 
<div class="as_options_sujet">
     <!-- BEGIN switch_user_logged_in -->
      <!-- BEGIN watchtopic -->
         {S_WATCH_TOPIC}
      <!-- END watchtopic -->
   <!-- END switch_user_logged_in -->
 
     <div class="as_moderer">
             {S_AUTH_LIST}
     </div>
</div>

<table>
     <tr>
      <!-- BEGIN moderation_panel -->
      <td align="center">
         <span class="gensmall">{moderation_panel.U_YOUR_PERSONAL_MODERATE}</span>
      </td>
      <td align="center" width="250">
         <span class="gensmall"> </span>
      </td>
      <!-- END moderation_panel -->
   </tr>
</table>

<!-- BEGIN viewtopic_bottom -->
<table class="noprint" width="100%" border="0" cellspacing="2" cellpadding="0" align="center">
   <tr>
      <td colspan="2" align="left" valign="top" nowrap="nowrap"><br />{S_TOPIC_ADMIN}<br />
         <form name="action" method="get" action="{S_FORM_MOD_ACTION}">
            <input type="hidden" name="t" value="{TOPIC_ID}" />

            <!-- <input type="hidden" name="sid" value="{S_SID}" /> -->
            <input type="hidden" name="{SECURE_ID_NAME}" value="{SECURE_ID_VALUE}" />

            <span class="gen">{L_MOD_TOOLS}<br />{S_SELECT_MOD} <input class="liteoption" type="submit" value="{L_GO}" /></span>
         </form>
      </td>
   </tr>
</table>
<!-- END viewtopic_bottom -->

<!-- BEGIN switch_image_resize -->
<script type="text/javascript">
//<![CDATA[
$(resize_images({ 'selector' : '.postbody', 'max_width' : {switch_image_resize.IMG_RESIZE_WIDTH}, 'max_height' : {switch_image_resize.IMG_RESIZE_HEIGHT} }));
//]]>
</script>
<!-- END switch_image_resize -->
<script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=forumotion" type="text/javascript"></script>

Penses a enregistrer puis à valider en cliquant respectivement sur  :enreg: puis  publié

a++
Milouze14

Milouze14
****

Masculin
Messages : 250
Inscrit(e) le : 03/12/2021

https://www.milouze14.net/
Milouze14 a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Couleur de groupe en fond de pseudo

Message par Aspen_Hayes Lun 25 Nov 2024 - 19:01

Bonsoir,

Ah, mais merci infiniment ! C'est justement ce que je ne comprenais pas dans le JS, la manière de récupérer la couleur etc. Avec tes explications, c'est beaucoup plus évident.
Tout fonctionne parfaitement et comme je le voulais Yahoo
Encore merci Hero
Aspen_Hayes

Aspen_Hayes
Nouveau membre

Messages : 26
Inscrit(e) le : 24/05/2023

https://monbordelnonorganise.forumactif.com/
Aspen_Hayes a été remercié(e) par l'auteur de ce sujet.

Voir le sujet précédent Voir le sujet suivant Revenir en haut

- Sujets similaires

Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum