The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
+2
Razor12345
eupdorguk
6 posters

    Staff colors without changing them in the editor

    eupdorguk
    eupdorguk
    New Member


    Posts : 24
    Reputation : 1
    Language : English

    Solved Staff colors without changing them in the editor

    Post by eupdorguk October 30th 2022, 7:36 pm

    Technical Details


    Forum version : #ModernBB
    Position : Founder
    Concerned browser(s) : Google Chrome
    Who the problem concerns : All members
    Forum link : https://community.eupd.org.uk

    Description of problem

    Hello all,

    I was hoping for somewhere you could point me to, possibly a tutorial or somewhere I can learn how to change staff colours, so for example, in a topic message a staff member is a purple colour in their text. I want to do this with code instead of having to do it from the text editor, so the code would automatically change the staffs colours to purple for example.


    Last edited by eupdorguk on October 31st 2022, 12:19 pm; edited 1 time in total
    Razor12345
    Razor12345
    Support Moderator
    Support Moderator


    Male Posts : 1575
    Reputation : 266
    Language : Ukr, Rus, Eng
    Location : Ukraine

    Solved Re: Staff colors without changing them in the editor

    Post by Razor12345 October 30th 2022, 10:37 pm




    Staff colors without changing them in the editor Screen51
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51498
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Staff colors without changing them in the editor

    Post by SLGray October 30th 2022, 10:47 pm

    I believe the member means text in messages, not usernames.



    Staff colors without changing them in the editor Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    eupdorguk
    eupdorguk
    New Member


    Posts : 24
    Reputation : 1
    Language : English

    Solved Re: Staff colors without changing them in the editor

    Post by eupdorguk October 30th 2022, 11:04 pm

    SLGray wrote:
    I believe the member means text in messages, not usernames.

    That is correct, I meant in text messages, without having to keep changing it in the text editor.
    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Solved Re: Staff colors without changing them in the editor

    Post by ÙƒÙˆÙ†Ø§Ù†2000 October 31st 2022, 1:31 am

    hi
    code java
    Placement : In the topics
    Code:
    (function($) {
        'use strict';
     
        $(function() {
            $('.post-wrap').each(function() {
                var $post = $(this);
              var color = $post.find('[style="color:xxxx"]').css('color');
     
                if (!color.length) return;
                $post
                   
                    .find('.post-content')
                    .css({
                        'color': 'yyyy'
                    });
            });
     
        });
    })(jQuery);

    Replace
    Code:
    xxxx
    with the color of the group
    Staff colors without changing them in the editor Ocia_a52

    Replace
    Code:
    yyyy
    with the text color you want to be for the group


    version AwesomeBB

    TonnyKamper and eupdorguk like this post

    eupdorguk
    eupdorguk
    New Member


    Posts : 24
    Reputation : 1
    Language : English

    Solved Re: Staff colors without changing them in the editor

    Post by eupdorguk October 31st 2022, 1:38 am

    كونان2000 wrote:hi
    code java
    Placement : In the topics
    Code:
    (function($) {
        'use strict';
     
        $(function() {
            $('.post-wrap').each(function() {
                var $post = $(this);
              var color = $post.find('[style="color:xxxx"]').css('color');
     
                if (!color.length) return;
                $post
                   
                    .find('.post-content')
                    .css({
                        'color': 'yyyy'
                    });
            });
     
        });
    })(jQuery);

    Replace
    Code:
    xxxx
    with the color of the group
    Staff colors without changing them in the editor Ocia_a52

    Replace
    Code:
    yyyy
    with the text color you want to be for the group


    version AwesomeBB


    Thanks for this, but unfortunately, that did not work. The text color is still the same. Staff colors without changing them in the editor Forums10
    Staff colors without changing them in the editor Forums10
    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Solved Re: Staff colors without changing them in the editor

    Post by ÙƒÙˆÙ†Ø§Ù†2000 October 31st 2022, 1:49 am

    hi
    new java code
    I added to it the color of your forum group
    https://community.eupd.org.uk/t7-my-introduction

    Code:
    (function($) {
     Â   'use strict';
     
     Â   $(function() {
     Â       $('.post-wrap').each(function() {
     Â           var $post = $(this);
     Â         var color = $post.find('[style="color:#744DB3"]').css('color');
     
     Â           if (!color.length) return;
     Â           $post
     Â               
     Â               .find('.post-content')
     Â               .css({
     Â                   'color': '#744DB3'
     Â               });
     Â       });
     
     Â   });
    })(jQuery);

    Check the java settings

    Staff colors without changing them in the editor Ocia_a37
    Staff colors without changing them in the editor Ocia_010

    eupdorguk likes this post

    eupdorguk
    eupdorguk
    New Member


    Posts : 24
    Reputation : 1
    Language : English

    Solved Re: Staff colors without changing them in the editor

    Post by eupdorguk October 31st 2022, 1:51 am

    Hi, still didn't unfortunately. Here's the settings. Staff colors without changing them in the editor Settin10

    Edit: It's changing everything else, but the text its self in a message.
    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Solved Re: Staff colors without changing them in the editor

    Post by ÙƒÙˆÙ†Ø§Ù†2000 October 31st 2022, 1:55 am

    I'm sorry, I made a mistake in editing the code

    Try the following new code
    Code:
    (function($) {
        'use strict';
     
        $(function() {
            $('.post-wrap').each(function() {
                var $post = $(this);
              var color = $post.find('[style="color:#744DB3"]').css('color');
     
                if (!color.length) return;
                $post
                   
                    .find('.post-content')
                    .css({
                        'color': '#744DB3'
                    });
            });
     
        });
    })(jQuery);

    TonnyKamper likes this post

    eupdorguk
    eupdorguk
    New Member


    Posts : 24
    Reputation : 1
    Language : English

    Solved Re: Staff colors without changing them in the editor

    Post by eupdorguk October 31st 2022, 1:57 am

    Thank you, how do I do, different colors for different ranks please?

    Edit: It seems to be working only on a certain thread, please can you advise on what to do next? Thank you.
    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Solved Re: Staff colors without changing them in the editor

    Post by ÙƒÙˆÙ†Ø§Ù†2000 October 31st 2022, 2:15 am

    hi

    We'll make a new one, wait for me tomorrow

    Very Happy
    eupdorguk
    eupdorguk
    New Member


    Posts : 24
    Reputation : 1
    Language : English

    Solved Re: Staff colors without changing them in the editor

    Post by eupdorguk October 31st 2022, 2:16 am

    كونان2000 wrote:hi

    We'll make a new one, wait for me tomorrow

    Very Happy

    As you can see from the tests I have done, it's no longer working for administrators now either, It just seems to be old messages. Thanks!
    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Solved Re: Staff colors without changing them in the editor

    Post by ÙƒÙˆÙ†Ø§Ù†2000 October 31st 2022, 4:22 am

    hi @eupdorguk

    code java
    Placement : In the topics
    Code:
    $(function() {
    var pseudos_couleur = ["xxxx","xxxx"];
    var color_texte_admin = "yyyy";
      function estPseudoCouleur(pseudo){
      for(i=0;i<pseudos_couleur.length;i++){   
        if(pseudo == pseudos_couleur[i]){        return true;      }  }  return false;}
    $(function() { 
      $("span.post-author-name strong").each(function(){ 
        if(estPseudoCouleur($(this).text())){   
        $(this).parents(".post-body").find(".post-content").css('color',color_texte_admin);
        }  });});
     
      });


    $(function() {
    var pseudos_couleur = ["xxxx","xxxx"];
    var color_texte_admin = "yyyy";
      function estPseudoCouleur(pseudo){
      for(i=0;i<pseudos_couleur.length;i++){   
        if(pseudo == pseudos_couleur[i]){        return true;      }  }  return false;}
    $(function() { 
      $("span.post-author-name strong").each(function(){ 
        if(estPseudoCouleur($(this).text())){   
        $(this).parents(".post-body").find(".post-content").css('color',color_texte_admin);
        }  });});
     
      });



    $(function() {
    var pseudos_couleur = ["xxxx","xxxx"];
      var color_texte_admin = "yyyy";
      function estPseudoCouleur(pseudo){
      for(i=0;i<pseudos_couleur.length;i++){   
        if(pseudo == pseudos_couleur[i]){        return true;      }  }  return false;}
    $(function() { 
      $("span.post-author-name strong").each(function(){ 
        if(estPseudoCouleur($(this).text())){   
        $(this).parents(".post-body").find(".post-content").css('color',color_texte_admin);
        }  });});
     
      });



    Replace
    Code:
    xxxx
    with usernames

    Replace
    Code:
    yyyy
    with the text color you want


    Put the text color you want below the usernames
    as in the picture
    Staff colors without changing them in the editor Ocia_011

    Razor12345 likes this post

    eupdorguk
    eupdorguk
    New Member


    Posts : 24
    Reputation : 1
    Language : English

    Solved Re: Staff colors without changing them in the editor

    Post by eupdorguk October 31st 2022, 10:54 am

    Unfortunately, these codes did not work.
    tikky
    tikky
    Forumember


    Posts : 922
    Reputation : 159
    Language : 🇵🇹

    Solved Re: Staff colors without changing them in the editor

    Post by tikky October 31st 2022, 12:02 pm

    Hello @eupdorguk,

    كونان2000 wrote:hi
    code java
    Placement : In the topics
    Code:
    (function($) {
        'use strict';
     
        $(function() {
            $('.post-wrap').each(function() {
                var $post = $(this);
              var color = $post.find('[style="color:xxxx"]').css('color');
     
                if (!color.length) return;
                $post
                   
                    .find('.post-content')
                    .css({
                        'color': 'yyyy'
                    });
            });
     
        });
    })(jQuery);
    version AwesomeBB
    Remove all scripts and replace by
    Code:
    (function($) {
        'use strict';
     
        $(function() {
            $('.post-wrap').each(function() {
                var $post = $(this);
              var color = $post.find('.post-author-name [style]').css('color');
     
                if (!color.length) return;
                $post
                 
                    .find('.post-content')
                    .css({
                        'color': color
                    });
            });
     
        });
    })(jQuery);

    SarkZKalie, TonnyKamper and Razor12345 like this post

    eupdorguk
    eupdorguk
    New Member


    Posts : 24
    Reputation : 1
    Language : English

    Solved Re: Staff colors without changing them in the editor

    Post by eupdorguk October 31st 2022, 12:18 pm

    You're both genius' thank you so much, this is solved now!

    كونان2000 likes this post

    كونان2000
    كونان2000
    Forumember


    Male Posts : 271
    Reputation : 113
    Language : Arabic

    Solved Re: Staff colors without changing them in the editor

    Post by ÙƒÙˆÙ†Ø§Ù†2000 October 31st 2022, 12:43 pm

    eupdorguk wrote:Unfortunately, these codes did not work.


    a stranger Think

    The code works in my test forum
    Staff colors without changing them in the editor Ocia_a54
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15311
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Solved Re: Staff colors without changing them in the editor

    Post by skouliki October 31st 2022, 3:01 pm

    topic marked as solved

    Problem solved & topic archived.
    Please read our forum rules: ESF General Rules


      Current date/time is September 22nd 2024, 6:28 pm