Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Very Simple Automatic Medals Based On Posts
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #1
Very Simple Automatic Medals Based On Posts
Updated: 16 Dec 2010. Thank you very much, Yumi Smile

This is a very simple automatic medals (I don't know how to call it) based on user's posts.

We need Template Conditionals plugin or PHP in Templates / Complex Templates plugin for this.
We will combine it with settings configuration.

  1. We will add a settings group for our automatic medals:
    AdminCP -> Configuration -> Add New Setting Group:
    • Title: Post Automatic Medal
      Modify it as our needs. This is the title of our automatic medals settings.
    • Description: Automatic medal based on user's posts
      Modify it as our needs. This is the description of our automatic medals settings.
    • Display Order: 500
      Modify it as our needs. This is the display order of our automatic medals settings.
    • Identifier: pam
  2. Then, we will add a setting for our first automatic medals condition:
    AdminCP -> Configuration -> Add New Setting:

    Basically, we only need to repeat this step as our needs.
    In this example, we will create two automatic medal.
    The first medal will be given to users who have at least one post in our forum, and the second medal will be given to users who have reached 100 posts in our forum.

    1. First posts condition and display/medal:
        First posts condition:
        • Title: #1 Post
          Modify it as our needs. This is the title of our first automatic medals condition.
        • Description: Number of posts for #1 automatic medal
          Modify it as our needs. This is the description of our first automatic medals condition.
        • Group: 'select the group setting in step #1'. In this example, Post Automatic Medal.
        • Display Order: 1
        • Identifier: pn1
        • Type: Text
        • Value: 1
          This is the minimum post number to get this medal.
        First automatic medal display:
        • Title: #1 Medal Display
          Modify it as our needs. This is the title of our first automatic medals display (output).
        • Description: How the #1 medal should be displayed?
          Modify it as our needs. This is the description of our first automatic medals display (output).
        • Group: 'select the group setting in step #1'. In this example, Post Automatic Medal.
        • Display Order: 2
        • Identifier: am1
        • Type: Textarea
          If the HTML code we use not too long, we can use Text in the setting above.
        • Value:

          HTML Code
          <img src="url_or_path_to_medal_image_1" alt="First Post" title="First Post" />

          Modify it as our needs.


        We need to put this code in ourpostbit_author_user template for this first automatic medal:

        Code:
        <if str_replace($mybb->settings['thousandssep'],'',$post['postnum']) >= $mybb->settings['pn1'] then>
        	{$mybb->settings['am1']}
        </if>

        Now, if our members have at least one post in our forum, they will have this medal, and the medal will be displayed in postbit.

    2. Second posts condition and display/medal:

      Like said before, we only need to repeat the step above.
      But we need to use a different identifier.
        First posts condition:
        • Title: #2 Post
        • Description: Number of posts for #2 automatic medal
        • Group: 'select the group setting in step #1'. In this example, Post Automatic Medal.
        • Display Order: 3
        • Identifier: pn2
          We use a different identifier here.
        • Type: Text
        • Value: 100
          This is the minimum post number to get this medal.
        Second automatic medal display:
        • Title: #2 Medal Display
        • Description: How the #2 medal should be displayed?
        • Group: 'select the group setting in step #1'. In this example, Post Automatic Medal.
        • Display Order: 4
        • Identifier: am2
          We use a different identifier here.
        • Type: Textarea
        • Value:

          HTML Code
          <img src="url_or_path_to_medal_image_2" alt="Reached 100 Posts" title="Reached 100 Posts" />

          Modify it as our needs.


        We need to put this code in ourpostbit_author_user template for this first automatic medal:

        Code:
        <if str_replace($mybb->settings['thousandssep'],'',$post['postnum']) >= $mybb->settings['pn2'] then>
        	{$mybb->settings['am2']}
        </if>

        Now, if our members have at 100 posts in our forum, they will have this medal, and the medal will be displayed in postbit.



We can edit each settings whenever we want, just like a normal plugin:
AdminCP -> Configuration -> Settings -> Post Automatic Medal.

If we want to display the medals in profile/header, just change the conditional codes.

That is our very simple automatic medals based on users posts and using Template Conditionals plugin or PHP in Templates / Complex Templates plugin Biggrin

Well, because I'm still noob, please tell me if I had made a mistake with the code above. Biggrin

Live Demo:
http://www.14.mynie.co.cc/showthread.php?tid=237
I have not put it in profile page. I still celebrate the presence of the new XThreads features Biggrin


Attached File(s) Thumbnail(s)
   

(This post was last modified: 05-08-2012 05:39 AM by RateU.)
12-15-2010 07:21 AM
Find all posts by this user Quote this message in a reply
1master1 Offline
Member
***
Posts: 232
Joined: Oct 2010
Post: #2
RE: Very SImple Automatic Medals Based On Posts
wow. this is awesome. rateu, you must hand over the development of further mybb versions Tongue
you will sure make mybb beat all other forum softwares with your innovative ideas. Wink
12-15-2010 07:50 PM
Find all posts by this user Quote this message in a reply
Imran Offline
Member
***
Posts: 204
Joined: Apr 2010
Post: #3
RE: Very SImple Automatic Medals Based On Posts
Nice.

[Image: logo.png]

[Image: twitter.png]
12-15-2010 08:56 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: Very SImple Automatic Medals Based On Posts
And this thing doesn't excessively query unlike some other similar plugins, lol Smile

Just wondering, is there a bug or similar for you to use this expression?

Code:
''.$mybb->settings['thousandssep'].''


My Blog
12-15-2010 10:00 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #5
RE: Very SImple Automatic Medals Based On Posts
Because I think in postbit_author_user, the $post['postnum'] already in my_number_format(), Yumi?
I don't know how to "revert" it back, so I can compare a user posts with the post setting Biggrin
Example:
User post = 1,000
Post setting to get a medal = 5

(This post was last modified: 12-16-2010 11:59 AM by RateU.)
12-16-2010 11:54 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #6
RE: Very SImple Automatic Medals Based On Posts
Yeah, I get that, just not sure why you chose

Code:
''.$mybb->settings['thousandssep'].''

instead of

Code:
$mybb->settings['thousandssep']


My Blog
12-16-2010 12:07 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #7
RE: Very SImple Automatic Medals Based On Posts
Ah, yes. It works. Thank you very much, Yumi Smile
I've updated the first post.

12-16-2010 12:39 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #8
RE: Very SImple Automatic Medals Based On Posts
"Combined" with XThreads additional parser setting (Custom Page):
http://www.14.mynie.co.cc/showthread.php?tid=296 Biggrin

(This post was last modified: 01-26-2011 07:38 AM by RateU.)
01-26-2011 07:26 AM
Find all posts by this user Quote this message in a reply
1master1 Offline
Member
***
Posts: 232
Joined: Oct 2010
Post: #9
RE: Very SImple Automatic Medals Based On Posts
is it possible to develop something like experience for user based on user - spent online time, no of posts, no of threads, no of reputations and assigning medals based on them?
01-29-2011 12:42 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #10
RE: Very SImple Automatic Medals Based On Posts
You'd just add more conditionals, though for number of threads, you'd need something like the thread count on postbit plugin.

My Blog
01-29-2011 08:50 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: