PHPBB Change Post Color - Small reward $

Discussion in 'Programming' started by adminworld, Jul 31, 2012.

  1. #1
    Ok so my PHPBB subsilver 2 has 2 post background colors. They change one after another. I would love that the first 2 post would have the same color and the color change would go only after second post. Can someone help me ? There is a $4 reward if someone can provide me the working code.

    P.S. dont ask me for any ACP accesses. You will have to provide me the code and i will insert myself.

    Thanks
     
    adminworld, Jul 31, 2012 IP
  2. mnmani

    mnmani Well-Known Member

    Messages:
    379
    Likes Received:
    11
    Best Answers:
    6
    Trophy Points:
    195
    #2
    first two posts again ! it is not easily possible on phpBB forum !!
     
    mnmani, Aug 1, 2012 IP
  3. Thorlax402

    Thorlax402 Member

    Messages:
    194
    Likes Received:
    2
    Best Answers:
    5
    Trophy Points:
    40
    #3
    This can be done with jquery. Here is a rough one-liner for the code you need:

    $('.post.bg2').first().addClass('bg1').removeClass('bg2');
    Code (markup):
    You will most likely put that in your themes header file.
     
    Thorlax402, Aug 1, 2012 IP
  4. adminworld

    adminworld Well-Known Member

    Messages:
    287
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    130
    #4
    No, i just want the background color for the first 2 post to be the same and continue switching after the second one. It seems that everything i am trying to do at phpbb is almost impossible.

    There are so many thing i could do with a WordPress and almost nothing with phpbb. grrrrrrrrrrrrrrr

    So when it come to my request, is it impossible or just hard ?
     
    adminworld, Aug 1, 2012 IP
  5. Thorlax402

    Thorlax402 Member

    Messages:
    194
    Likes Received:
    2
    Best Answers:
    5
    Trophy Points:
    40
    #5
    That is exactly what the snippet I provided will do. Each post on a phpbb thread is wrapped in a <div> tag with a class attribute of either "bg1" or "bg2" and each post alternates which one (this is how the colors are set). The snippet I provided will take the first posts class (oddly bg2 instead of bg1) and replace it with bg1. This will effectively make the first two posts have the same background color and then the rest will continue to alternate.
     
    Thorlax402, Aug 1, 2012 IP
  6. adminworld

    adminworld Well-Known Member

    Messages:
    287
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    130
    #6
    Hmmm ok let me try it. I will copy and paste this but i need the exact location. Could you post a line after with once i need to insert it. Also, are u sure its in a header instead of viewtopic_body.html ?
     
    adminworld, Aug 1, 2012 IP
  7. Thorlax402

    Thorlax402 Member

    Messages:
    194
    Likes Received:
    2
    Best Answers:
    5
    Trophy Points:
    40
    #7
    technically, there are a number of places you could put it, but the <head> tag of the webpage is common practice. To place this properly, put the following in the header file above the </head> tag:

    <script type="text/javascript">
    $(document).ready(function() {
        $('.post.bg2').first().addClass('bg1').removeClass('bg2');
    });
    </script>
    Code (markup):
    That should do the trick.
     
    Thorlax402, Aug 2, 2012 IP
  8. adminworld

    adminworld Well-Known Member

    Messages:
    287
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    130
    #8
    I have placed this code on overall_header.html just above the </head> but nothing happened. Is that maybe the wrong place to place ? Still need help guys !
     
    adminworld, Aug 6, 2012 IP
  9. mnmani

    mnmani Well-Known Member

    Messages:
    379
    Likes Received:
    11
    Best Answers:
    6
    Trophy Points:
    195
    #9
    find below code on viewtopic_body.html
    <!-- IF postrow.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
                       <td valign="top" class="profile">
    Code (markup):
    replace with below code
    <!-- IF postrow.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
                  <!-- IF postrow.S_FIRST_ROW --><tr class="row2"><!-- ENDIF -->
    		 <td valign="top" class="profile">
    Code (markup):
    that is, we are changing background of first post ;
    first post will have the same background of second post (all even numbered posts)

    alternating background colors will start from third post

    Edit :
    it is also possible to add a new background color for the first two posts.
    regular alternate colors start from the third post ..
     
    Last edited: Aug 7, 2012
    mnmani, Aug 7, 2012 IP