XF 2.0 Custom Rank Badges per Users Posts Count

Donske

Active member
I am not sure if I am supposed to request this in this section, so I apologize in advance if I did. I wish I knew php more than I did. But, beside that point, this is what I really would like to do:

Based on a users number of post (or I guess points), I would like to have my own ranking "Badge". So, I included an image of some Badges and also the number of post that is required before the member advances to the next level.

I also included a graphic that I edited that I inserted a Badge as an example of what I would like.

I would appreciate any tips on how to do this. I don't think there is an add-on for this yet, but I am sure that there has to be some code that I can "tie" the post count with inserting the ranking badge.

Many thanks
Donnie
ranks02.webpranks03.webp
 
I was just wondering if anyone had any ideas, tips, links of where I can find any info on how to do this. I would really be appreciative. I did find some info, but it pertains to much older versions of XF of some custom work a few (very few) individuals done.

What would be the Template "name" to modify ?

If I could at least get some ideas, then maybe I can figure this out, but I am not a programmer. I just started self study on MySQL and PHP, but if I was given a little info, I would be able to insert the data where it needs to be to do this.
Thanks
Donnie
 
You can do that editing the message_macros template and using this conditional
Code:
<xf:if is="$user.message_count >= 15">
    <img src="rank3.png">
<xf:elseif is="$user.message_count >= 10" />
    <img src="rank2.png">
<xf:elseif is ="$user.message_count >= 5" />
    <img src="rank1.png">
</xf:if>
 
Thank you - thank you !!! DL6 ! :)
this might help me get past the hurdle. I was just looking at the templates and I passed right by the message_macros looking elsewhere. Now to see where to plug this in.

Donnie
 
Ok, so I plugged the code in (I think I followed the correct formatting) and when I save the code, it says that it ran into problems. Template tags are not well formed. Tag contentcheck was found when expecting if.
the line in question has this: </xf:countercheck> I don't think I have my code is placed in correct location.
I have attached txt file.

thanks
Donnie
 

Attachments

Ok, I got one Rank Badge working. I narrowed my code to

Code:
<xf:if is="$user.message_count >= 15">
    <img src="rank1.png">

I then uploaded a test image as rank1.png and uploaded it to the root of the forum and I now have an image. Now onward to make the rest of it work.

I nested this right after the "points"
 
Based in the image this the correct code
Code:
                    <xf:if is="$user.message_count >= 5000">
                        <img src="rank10.png">
                    <xf:elseif is="$user.message_count >= 4000" />
                        <img src="rank9.png">
                    <xf:elseif is="$user.message_count >= 3000" />
                        <img src="rank8.png">
                    <xf:elseif is="$user.message_count >= 2000" />
                        <img src="rank7.png">
                    <xf:elseif is="$user.message_count >= 1000" />
                        <img src="rank6.png">
                    <xf:elseif is="$user.message_count >= 500" />
                        <img src="rank5.png">
                    <xf:elseif is="$user.message_count >= 250" />
                        <img src="rank4.pngg">
                    <xf:elseif is="$user.message_count >= 100" />
                        <img src="rank3.png">
                    <xf:elseif is="$user.message_count >= 50" />
                        <img src="rank2.png">
                    <xf:elseif is ="$user.message_count >= 5" />
                        <img src="rank1.png">
                    </xf:if>
 
In case anyone wants to add badges and or ranks under the profile on post, then I want to thank "DL6" for getting me started and now here is the final working code added and it was added right after this line:
Note: I created my own folder "ranks".


Code:
<xf:if is="$extras.trophy_points && $xf.options.enableTrophies">
                        <dl class="pairs pairs--justified">
                            <dt>{{ phrase('points') }}</dt>
                            <dd>{$user.trophy_points|number}</dd>
                        </dl>
                    </xf:if>
                                        
 <!-- this adds the Rank Badge Count-->

Code:
<!-- this adds the Rank Badge Count-->
                    <xf:if is="$user.message_count >= 5000">
                        <br>
                        <div align="center"><img src="styles/default/xenforo/ranks/11masterchiefpettyofficerofnavy.png"></div>
                         <xf:elseif is="$user.message_count >= 4000"/>
                        <br>
                         <div align="center"><img src="styles/default/xenforo/ranks/10fleetmasterpettyofficer.png"></div>
                        <xf:elseif is ="$user.message_count >= 3000"/>
                         <br>
                        <div align="center"><img src="styles/default/xenforo/ranks/09commandmasterchiefpettyofficer.png"></div>
                        <xf:elseif is ="$user.message_count >= 2000"/>
                         <br>
                        <div align="center"><img src="styles/default/xenforo/ranks/08masterchiefpettyofficer.png"></div>   
                        <xf:elseif is ="$user.message_count >= 1000"/>
                         <br>
                        <div align="center"><img src="styles/default/xenforo/ranks/07seniorchiefpettyofficer.png"></div>
                        <xf:elseif is ="$user.message_count >= 500"/>
                         <br>
                        <div align="center"><img src="styles/default/xenforo/ranks/06chiefpettyofficer.png"></div>   
                        <xf:elseif is ="$user.message_count >= 250"/>
                         <br>
                        <div align="center"><img src="styles/default/xenforo/ranks/05pettyofficerfirstclass.png"></div>
                        <xf:elseif is ="$user.message_count >= 100"/>
                         <br>
                        <div align="center"><img src="styles/default/xenforo/ranks/04pettyofficersecondclass.png"></div>
                        <xf:elseif is ="$user.message_count >= 50"/>
                         <br>
                        <div align="center"><img src="styles/default/xenforo/ranks/03pettyofficerthirdclass.png"></div>   
                        <xf:elseif is ="$user.message_count >= 10"/>
                         <br>
                        <div align="center"><img src="styles/default/xenforo/ranks/02seaman.png"></div>
                        <xf:elseif is ="$user.message_count >= 5"/>
                         <br>
                        <div align="center"><img src="styles/default/xenforo/ranks/01seamanapprentice.png"></div>   
                    </xf:if>
                    <!-- this adds the Rank Badge Count-->
 
Where in the template would I place the code if I wanted the image to appear next to the username to the right of the username?

Something like this:
 

Attachments

  • star10.gif
    star10.gif
    4.2 KB · Views: 2
Hi Guys - I really appreciate the feedback. Actually, I am just barely a programmer and looked at some of the code to "figure out" how to add badges of my own. I would have to go back to see what I did to figure out how to address DarkGizmo and AndreaMarucci additions. If I am able to figure both out, I will let you know.
 
Thanks Donske with the help of some other guys I've figured out how to fix that. See here

 
Back
Top Bottom