MyBB Hacks

Full Version: Very Simple Automatic Medals Based On Posts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
For some reason this doesn't work using Template Conditionals plugin, I think the reason is because of the code, I don't understand it but it looks like it is a advanced code than can only be used with PHP in Templates / Complex Templates plugin.

I mean this code:

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


I tried to 'modify' it and it did worked:

PHP Code:
<if $mybb->settings['thousandssep'] + $post['postnum'] >


Is that code right?

It should work with the Template Conditionals plugin, and no, your code isn't correct unfortunately.
I have not plugins intalled and I'm using mybb 1.6.3 but it doesn't work, it doesn't show a error code or something, it just don't show up Ouch

And sorry, I copy/paste it wrong, the code I modify is now this:

PHP Code:
<if $mybb->settings['thousandssep'] + $post['postnum'] >= $mybb->settings['pn2'] then>


Edit: I'm using a almost clean localhost installation to test this.

It doesn't make sense to add a thousands separator to the number of posts.

And are you using 'pn1' or 'pn2' ?  You should be comparing with the number (pn1), not the HTML (pn2).

Can you put the following into your template and post the output generated by it?

HTML Code
<div>Thousands Separator: {$mybb->settings['thousandssep']}</div>
<div>Post Num: {$post['postnum']}</div>
<div>PN1: {$mybb->settings['pn1']}</div>

(07-22-2011 02:55 PM)ZiNgA BuRgA Wrote: [ -> ]It doesn't make sense to add a thousands separator to the number of posts.

Now I removed it and it worked:

PHP Code:
<if $post['postnum'] >= $mybb->settings['pn2'] then>

---

(07-22-2011 02:55 PM)ZiNgA BuRgA Wrote: [ -> ]And are you using 'pn1' or 'pn2' ?  You should be comparing with the number (pn1), not the HTML (pn2).
I'm using both, I just did the complete tutorial and I paste this in my postbit_author_user:

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


But because it didn't worked I then edited like this:

PHP Code:
<if $mybb->settings['thousandssep'] + $post['postnum'] >= $mybb->settings['pn1'] then>
	{$mybb->settings['am1']}
</if>
<if $mybb->settings['thousandssep'] + $post['postnum'] >= $mybb->settings['pn2'] then>
	{$mybb->settings['am2']}
</if>


Or this (what also worked), as you mentioned, it what useless to use a thousands separator:

PHP Code:
<if $post['postnum'] >= $mybb->settings['pn1'] then>
	{$mybb->settings['am1']}
</if>
<if $post['postnum'] >= $mybb->settings['pn2'] then>
	{$mybb->settings['am2']}
</if>

---

(07-22-2011 02:55 PM)ZiNgA BuRgA Wrote: [ -> ]Can you put the following into your template and post the output generated by it?

HTML Code
<div>Thousands Separator: {$mybb->settings['thousandssep']}</div>
<div>Post Num: {$post['postnum']}</div>
<div>PN1: {$mybb->settings['pn1']}</div>

Code:
Thousands Separator: ,
Post Num: 105
PN1: 1


I also checked PN2:
PN2 = 100

I don't know why the code doesn't work for you. I've tested using Template Conditional, and it works for me.

As far as I know (I can be wrong), the $post['postnum'] variable already formatted in postbit_author_user template. Maybe the comparison won't work correctly if we don't remove the thousand separator from the formatted $post['postnum'].

Example:
If we set the minimum post to get the 2nd Medal to 100 post, the user will get the medal when he/she has 100 - 999 post. Maybe he/she will lost it when he/she has 1000 - 1999 posts, or/and 10000 - 19999 posts.
Can you try doing a complete reinstall?
That is, start from a completely fresh MyBB 1.6.3, and a fresh Template Conditionals plugin.
I have a feeling you don't have a phptpl_allowed_funcs.txt file.
Oh well, I thought phptpl_allowed_funcs.txt was a readme file for us to read so I never upload it, that was the problem.

I'm really sorry for taking and wasting your time RateU and ZiNgA BuRgA -.-
Hello together, i have a question to.
Is it possible to do this manually on a specific user id to set?

Thanks
Maybe if you wrap an <if> condition around everything.
Note that the more conditionals you set, the more complicated things get.
Pages: 1 2 3
Reference URL's