Post Number for phpBB3 Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

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.
+4
Eugeo Igvalt
AlexisMcDevin
Michael_vx
Mati
8 posters

    Post Number for phpBB3

    Mati
    Mati
    Active Poster


    Posts : 1932
    Reputation : 333
    Language : HTML, CSS & JavaScript
    Location : Forum Services

    Solved Post Number for phpBB3

    Post by Mati December 28th 2014, 10:25 pm

    I would like to add a post number count on every post for phpBB3

    Ex:
    Post Number: #1
    Post Number: #2
    Post Number: #3


    Last edited by Mati™ on January 2nd 2015, 11:22 am; edited 1 time in total
    Mati
    Mati
    Active Poster


    Posts : 1932
    Reputation : 333
    Language : HTML, CSS & JavaScript
    Location : Forum Services

    Solved Re: Post Number for phpBB3

    Post by Mati December 30th 2014, 12:20 pm

    Any answer for this?
    Michael_vx
    Michael_vx
    Forumember


    Male Posts : 659
    Reputation : 29
    Language : Arabic and some English
    Location : Egypt

    Solved Re: Post Number for phpBB3

    Post by Michael_vx December 30th 2014, 3:23 pm

    i think this could work
    in javascript


    Code:
    var CopyrightNotice = 'Copyright Code By Sam Hameed & my-as7ab.com';$(function(){$(".hr").each(function(index){$(this).after(" <strong>  مساهمة[</strong><font color='red'>"+index+"</font><strong>] </strong>")})});
    AlexisMcDevin
    AlexisMcDevin
    Forumember


    Male Posts : 134
    Reputation : 5
    Language : English

    Solved Re: Post Number for phpBB3

    Post by AlexisMcDevin December 30th 2014, 4:00 pm

    Michael_vx wrote:i think this could work
    in javascript


    Code:
    var CopyrightNotice = 'Copyright Code By Sam Hameed & my-as7ab.com';$(function(){$(".hr").each(function(index){$(this).after(" <strong>  مساهمة[</strong><font color='red'>"+index+"</font><strong>] </strong>")})});

    I also need this. Above code did not work.
    Mati
    Mati
    Active Poster


    Posts : 1932
    Reputation : 333
    Language : HTML, CSS & JavaScript
    Location : Forum Services

    Solved Re: Post Number for phpBB3

    Post by Mati December 30th 2014, 6:36 pm

    Nothing really happen  Confused
    Eugeo Igvalt
    Eugeo Igvalt
    Forumember


    Male Posts : 289
    Reputation : 17
    Language : EN, SPA
    Location : Puerto Rico

    Solved Re: Post Number for phpBB3

    Post by Eugeo Igvalt December 30th 2014, 6:58 pm

    It's not working. I would also like to have this.
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Post Number for phpBB3

    Post by _Twisted_Mods_ December 30th 2014, 7:11 pm

    you you want the # to start over on each page or keep going up?
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Post Number for phpBB3

    Post by Ange Tuteur December 30th 2014, 7:15 pm

    Hi @Mati™,

    You can edit the viewtopic_body template to add {postrow.displayed.COUNT_POSTS_NUMBER} wherever you like. The result would be : Post n°57, but if you don't want that you can modify the variable like this :
    Code:
    <span class="postNumber">{postrow.displayed.COUNT_POSTS_NUMBER}</span><script type="text/javascript">(function(){var tag = '#'; for (var i=0,n=document.getElementsByTagName('SPAN'); i<n.length; i++) if (/postNumber/.test(n[i].className)) n[i].innerHTML = n[i].innerHTML.replace(/^.*?n°(\d+)/,tag+'$1')})();</script>

    The tag variable in the script determines the tag next to the number. If you just want the number you can leave the string blank. e.g. tag = '';
    Mati
    Mati
    Active Poster


    Posts : 1932
    Reputation : 333
    Language : HTML, CSS & JavaScript
    Location : Forum Services

    Solved Re: Post Number for phpBB3

    Post by Mati December 30th 2014, 7:29 pm

    @Ange Tuteur

    How to make it clickable like when you click on it it will pop up a box with the link for that post.
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Post Number for phpBB3

    Post by _Twisted_Mods_ December 30th 2014, 7:40 pm

    i have the script finished just need know how the link goes for directing to a certain post


    update

    Code:
    $(function(){
    torb = "top"
    lorr = "right"
    $('#main-content .post').each(function(index){
      var count1 = $('.pagination:last>strong:first').text();
      count2 = index;
     if(count1>1){  count2 = $('#main-content .post').length+index*count1}

      turl = $(this).attr('id')
      turl = location.href + "#" + turl
      if (torb=="top"){
        if (lorr=="left"){ $(this).prepend(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> '); }else{$(this).prepend(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> '); }
      }else{
        if (lorr=="left"){$(this).append(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> '); }else{$(this).append(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');    }
    }
    })
    });
    AlexisMcDevin
    AlexisMcDevin
    Forumember


    Male Posts : 134
    Reputation : 5
    Language : English

    Solved Re: Post Number for phpBB3

    Post by AlexisMcDevin December 30th 2014, 8:19 pm

    I am sorry to jump here.

    I tried with three ways above but nothing happening.

    @"Mati™" Do you try these yet?
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Post Number for phpBB3

    Post by _Twisted_Mods_ December 30th 2014, 8:24 pm

    my fault try this

    Code:
        $(function(){
        torb = "top";
        lorr = "right";
        $('#main-content .post').each(function(index){
          var count1 = $('.pagination:last>strong:first').text();
          count2 = index;
        if(count1>1){  count2 = $('#main-content .post').length+index*count1;}

          turl = $(this).attr('id');
          turl = location.href + "#" + turl;
          if (torb=="top"){
            if (lorr=="left"){
              $(this).prepend(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
            }else{
              $(this).prepend(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
            }
          }else{
            if (lorr=="left"){
              $(this).append(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
            }else{
              $(this).append(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
            }
        }
        })
        });
    AlexisMcDevin
    AlexisMcDevin
    Forumember


    Male Posts : 134
    Reputation : 5
    Language : English

    Solved Re: Post Number for phpBB3

    Post by AlexisMcDevin December 30th 2014, 8:37 pm

    @_Twisted_Mods_,

    It worked but the button in left hand. It should be at right hand, right? Can you make text bold?

    I edit my post because we have one more problem. All the number are in even number.

    Post Number for phpBB3 10887630_689563461157599_1796086422122231881_o


    Last edited by AlexisMcDevin on December 30th 2014, 8:48 pm; edited 1 time in total (Reason for editing : show more detail)
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Post Number for phpBB3

    Post by _Twisted_Mods_ December 30th 2014, 8:52 pm

    Code:
     torb = "top";
        lorr = "right";

    torb = top or bottom

    lorr = left or right

    you can set where its located

    also you can style it in css with

    #ppostc{}

    example

    Code:
    #ppostc {
        font-weight: bold;
        font-size: 1em;
        border: 1px solid white;
        width: 50px;
        text-align: center;
        border-radius: 5px;
        background-color: gray;
        color: black !important;
    }
    AlexisMcDevin
    AlexisMcDevin
    Forumember


    Male Posts : 134
    Reputation : 5
    Language : English

    Solved Re: Post Number for phpBB3

    Post by AlexisMcDevin December 30th 2014, 9:18 pm

    @_Twisted_Mods_,

    Can you review my post above again. May I edited my post while you are working, so you do not know that.

    All the numbers are in even number. Like: #20, #22, #24,...

    And I changed lorr = "left", however, the post number does not move to another side.
    Mati
    Mati
    Active Poster


    Posts : 1932
    Reputation : 333
    Language : HTML, CSS & JavaScript
    Location : Forum Services

    Solved Re: Post Number for phpBB3

    Post by Mati December 30th 2014, 9:34 pm

    _Twisted_Mods_ wrote:my fault try this

    Code:
        $(function(){
        torb = "top";
        lorr = "right";
        $('#main-content .post').each(function(index){
          var count1 = $('.pagination:last>strong:first').text();
          count2 = index;
        if(count1>1){  count2 = $('#main-content .post').length+index*count1;}

          turl = $(this).attr('id');
          turl = location.href + "#" + turl;
          if (torb=="top"){
            if (lorr=="left"){
              $(this).prepend(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
            }else{
              $(this).prepend(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
            }
          }else{
            if (lorr=="left"){
              $(this).append(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
            }else{
              $(this).append(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
            }
        }
        })
        });

    @_Twisted_Mods_

    How to make it clickable like when you click on it it will pop up a box with the link for that post.
    AlexisMcDevin
    AlexisMcDevin
    Forumember


    Male Posts : 134
    Reputation : 5
    Language : English

    Solved Re: Post Number for phpBB3

    Post by AlexisMcDevin December 30th 2014, 10:02 pm

    Hi @Mati™,

    Have you applied your code yet? I changed all Left by right but the post numbers are still in left.

    And we have more problem:

    - In the page No.1, post number showed like this: #0, #1, #2, #3,....,#9. (First page works well)
    - In the page No.2, post number showed like this: #10, #12, #14,..., #28. (all in even number).
    - In the page No.3, post number showed like this: #10, #13, #16,...,#37.

    I do not know why!

    Please come to my forum and check this @ HERE
    Mati
    Mati
    Active Poster


    Posts : 1932
    Reputation : 333
    Language : HTML, CSS & JavaScript
    Location : Forum Services

    Solved Re: Post Number for phpBB3

    Post by Mati December 30th 2014, 10:08 pm

    Just change your CSS with this.

    Code:
    #ppostc {
        background-color: #d3d3d3;
        border: 1px solid #fff;
        border-radius: 5px;
        color: #000 !important;
        font-size: 1em;
        font-weight: 700;
        text-align: center;
        width: 50px;
        float: right;
    }
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Post Number for phpBB3

    Post by _Twisted_Mods_ December 30th 2014, 10:19 pm

    ok give me min i prob did my mah wrong in the code... matti i added ur popup just give me sec to check the post on second page
    Mati
    Mati
    Active Poster


    Posts : 1932
    Reputation : 333
    Language : HTML, CSS & JavaScript
    Location : Forum Services

    Solved Re: Post Number for phpBB3

    Post by Mati December 30th 2014, 10:27 pm

    _Twisted_Mods_ wrote:ok give me min i prob did my mah wrong in the code... matti i added ur popup just give me sec to check the post on second page

    @Ange Tuteur, code start counting from 1 and yours from 0 so can you make it to count from 1 instead 0.
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Post Number for phpBB3

    Post by _Twisted_Mods_ December 30th 2014, 10:30 pm

    ok everything should be good now

    Code:

            $(function(){
            
            torb = "top";
            lorr = "right";
            $('#main-content .post').each(function(index){
              var count1 = $('.pagination:last>strong:first').text();
              count2 = index;
            if(count1>1){  count2 = ($('#main-content .post').length-1*count1)+index;}

              turl = $(this).attr('id');
              turl = location.href + "#" + turl;
              if (torb=="top"){
                if (lorr=="left"){
                  $(this).prepend(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
                }else{
                  $(this).prepend(' <div id="ppostc" style="float:right;"><a href="'+turl+'">#'+count2+'</a></div> ');
                }
              }else{
                if (lorr=="left"){
                  $(this).append(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
                }else{
                  $(this).append(' <div id="ppostc" style="float:right;"><a href="'+turl+'">#'+count2+'</a></div> ');
                }
            }
            })
            $('#ppostc a').click(function() {
            alert($(this).attr("href"));
            });
            });
    AlexisMcDevin
    AlexisMcDevin
    Forumember


    Male Posts : 134
    Reputation : 5
    Language : English

    Solved Re: Post Number for phpBB3

    Post by AlexisMcDevin December 30th 2014, 10:36 pm

    Opps, all post numbers are lost!

    Can you try again?

    Thank you!
    Mati
    Mati
    Active Poster


    Posts : 1932
    Reputation : 333
    Language : HTML, CSS & JavaScript
    Location : Forum Services

    Solved Re: Post Number for phpBB3

    Post by Mati December 30th 2014, 10:39 pm

    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Post Number for phpBB3

    Post by _Twisted_Mods_ December 30th 2014, 10:51 pm

    lol im messing up alot today


    Code:
            $(function(){
           
            torb = "top";
            lorr = "right";
            $('#main-content .post').each(function(index){
              var count1 = $('.pagination:last>strong:first').text();
              count2 = index+1;
            if(count1>1){  count2 = ($('#main-content .post').length-1*count1)+index+1;}

              turl = $(this).attr('id');
              turl = location.href + "#" + turl;
              if (torb=="top"){
                if (lorr=="left"){
                  $(this).prepend(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
                }else{
                  $(this).prepend(' <div id="ppostc" style="float:right;"><a href="'+turl+'">#'+count2+'</a></div> ');
                };
              }else{
                if (lorr=="left"){
                  $(this).append(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
                }else{
                  $(this).append(' <div id="ppostc" style="float:right;"><a href="'+turl+'">#'+count2+'</a></div> ');
                };
            };
            });
            $('#ppostc a').click(function() {
            alert($(this).attr("href"));
            });
            });
    AlexisMcDevin
    AlexisMcDevin
    Forumember


    Male Posts : 134
    Reputation : 5
    Language : English

    Solved Re: Post Number for phpBB3

    Post by AlexisMcDevin December 30th 2014, 11:00 pm


    I still have problem with post number like below:

    - Page No.1: #1, #2, #3,....#9, #10 (Okay)
    - Page No.2: #9, # 10, #11,..., #17, #18 ( repeat #9 and #10)
    - Page No.3: #8, #9, #10,..., #16, #17 (Wrong number)

    Please try this again!
    Thank you!
    Mati
    Mati
    Active Poster


    Posts : 1932
    Reputation : 333
    Language : HTML, CSS & JavaScript
    Location : Forum Services

    Solved Re: Post Number for phpBB3

    Post by Mati December 30th 2014, 11:05 pm

    Yes is not counting correct I have 15 post per page after 15 is not counting 16 17 18 and so on...
    AlexisMcDevin
    AlexisMcDevin
    Forumember


    Male Posts : 134
    Reputation : 5
    Language : English

    Solved Re: Post Number for phpBB3

    Post by AlexisMcDevin December 30th 2014, 11:25 pm

    Mati™ wrote:Yes is not counting correct I have 15 post per page after 15 is not counting 16 17 18 and so on...

    Hi Mati,

    Sorry again to make some noise into your topic!

    I have a question from here. Can you come there?

    Thank you!
    Michael_vx
    Michael_vx
    Forumember


    Male Posts : 659
    Reputation : 29
    Language : Arabic and some English
    Location : Egypt

    Solved Re: Post Number for phpBB3

    Post by Michael_vx December 30th 2014, 11:32 pm

    _Twisted_Mods_ wrote:lol im messing up alot today


    Code:
            $(function(){
            
            torb = "top";
            lorr = "right";
            $('#main-content .post').each(function(index){
              var count1 = $('.pagination:last>strong:first').text();
              count2 = index+1;
            if(count1>1){  count2 = ($('#main-content .post').length-1*count1)+index+1;}

              turl = $(this).attr('id');
              turl = location.href + "#" + turl;
              if (torb=="top"){
                if (lorr=="left"){
                  $(this).prepend(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
                }else{
                  $(this).prepend(' <div id="ppostc" style="float:right;"><a href="'+turl+'">#'+count2+'</a></div> ');
                };
              }else{
                if (lorr=="left"){
                  $(this).append(' <div id="ppostc"><a href="'+turl+'">#'+count2+'</a></div> ');
                }else{
                  $(this).append(' <div id="ppostc" style="float:right;"><a href="'+turl+'">#'+count2+'</a></div> ');
                };
            };
            });
            $('#ppostc a').click(function() {
            alert($(this).attr("href"));
            });
            });
    after test working with phpbb3 and punbb good Smile
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Post Number for phpBB3

    Post by Ange Tuteur December 30th 2014, 11:33 pm

    @AlexisMcDevin, please take such conversation to Private Messages. Wink

    @Mati™️, try this :

    Go to Administration Panel > Display > Templates > General > viewtopic_body Edit

    Find :
    Code:
    <div style="position: relative; top: -30px; width: 1px;" id="{postrow.displayed.U_POST_ID}"></div>

    Replace by :
    Code:
    <div style="position: relative; top: -30px; width: 1px;" id="{postrow.displayed.U_POST_ID}"></div>
    <div class="postNumberContainer"><a href="{postrow.displayed.POST_URL}" class="postNumber">#{postrow.displayed.COUNT_POSTS}</a></div>

    Save and publish Add

    Use CSS to change the alignment :
    Display > Colors > CSS stylesheet
    Code:
    .postNumberContainer { text-align:right }
    Michael_vx
    Michael_vx
    Forumember


    Male Posts : 659
    Reputation : 29
    Language : Arabic and some English
    Location : Egypt

    Solved Re: Post Number for phpBB3

    Post by Michael_vx December 31st 2014, 1:19 am

    @Ange Tuteur
    is this code for phpbb2 or can work on any version Very Happy
    i like to collect info Very Happy
    thanks
    and sorry for my unhelpful code