1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Add-on Post percentage

Discussion in 'Resource and Add-on Requests' started by Hyperion, Jan 13, 2012.

  1. Hyperion

    Hyperion Active Member

    When I was using vBulletin 3.x, there was an add-on that displayed the percentage that a member's post count took up from the total post count of the forum. For example, with 3000 posts my post count might be indicated as taking up 5.03% of the total. Post count was displayed on the threads pages like this: Posts: 3,000 (5.03%)

    xenForo does not display post count by default on the threads pages, but it still shows it as "Messages" on the Member Card and in the Profile. I want to see percentage show up beside the post count on said pages.

    Is that easy to do?
  2. Floris

    Floris Guest

    There are a few things I have to figure out, but it's perhaps possible.
    Using xen:container we can get {xen:number $boardTotals.messages}
    And by injecting our custom template into the template forum_list where there's a hook forum_list_sidebar for the sidebar.

    Once we have the var, we can display it in any other template. Which we need to do the calculation.

    Or, perhaps i can just get the stuff in php first, skipping the above part, and calculate in PHP directly and return a $post_percentage to be used in a specified template (if there's a hook available)

    Anyway, when you know your amount of posts $myPosts
    and you know the board totals $allPosts
    Then it's just a matter of course of $myPercentage = ( $myPosts / $allPosts ) * 100
    And then round it, floor it, whatever it's called, and limit it to 2 decimals.

    forum_list [forum_list_sidebar]
    <xen:container var="$allPosts">{xen:number $boardTotals.messages}</xen:container>

    whatevertemplate [whateverhook]
    <xen:container var="$userPosts">{$user.message_count}</xen:container>

    whichevertemplatewewannaidplay [whateverhookthereis]
    <xen:set var="$postPercentage">{xen:calc '({$userPosts} / {$allPosts}) * 100'}</xen:set>

    (no idea in a template how to limit the outcome to just 2 decimals.)

    And then $myPercentage could be used.

    My time isn't going to be much, don't expect me to have done this in a week, but I hope I can figure some stuff out, or perhaps someone else.

Share This Page