MyBB Community Forums

Full Version: Template conditional thousands sumeric separator remove comma
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
I have just found a bug please fix it. When user has more than 1000 posts this kind of conditional won't work!!
<div><if $post['postnum'] <= 10 then>Hello</if></div>
<div><if $post['postnum'] >= 10 then>Hello</if></div>
<div><if $post['postnum'] == 10 then>Hello</if></div>
does the user has more than 1000 posts ? see if this earlier thread has the clue
.M. buddy YES it has 1003 posts. Any idea how to fix template conditional?
It's not a bug of Template Conditionals... Where did you insert that code? It will work only in postbit templates. Also, it checks 10 and not 1000.

EDIT: also the topic .m. mentioned may be a solution. You can check $postnum instead of $post['postnum'], it stores the int value.
D666 buddy the problem is in the comma 1,003 the template conditional seems to have issue with numbers that have comma: my_number_format

Any idea how to make the plugin strip the comma without changing: Thousands Numeric Separator

Edit...

Thanks guys very much works great Smile
<if $postnum >= 10 then>Show</if>

Update...

Guys how to fix these so that they won't show comma separator?

$memprofile['postnum']
$post['reputation']
$post['referrals']
Using template conditionals, something like the following may work.
<if str_replace(array($mybb->settings['decpoint'], $mybb->settings['thousandssep']), '', $memprofile['postnum']) >= 10>I have 10 posts! Or more..</if>
@Omar G buddy thanks very much for your help BUT ain't working sorry.

Is there a global value for user posts? $mybb->user['postnum']


Edit I decided to hook to global.php and use this code:


​$query1 = $db->query("
			SELECT u.postnum, u.reputation, u.referrals, u.uid
			FROM ".TABLE_PREFIX."users u
			WHERE u.uid = ".intval($mybb->input['uid'])."
		");
while ($users = $db->fetch_array($query1)) {
		$custompostnum = $users['postnum'];
		$customreputation = $users['reputation'];
		$customreferrals = $users['referrals'];
	}
Could you please check it to make sure it will not put extra load on my script?
(2014-08-12, 03:14 PM)marcus123 Wrote: [ -> ]Thanks guys very much works great Smile

<if $postnum >= 10 then>Show</if>

So, does this code work for you or not? I'm confused now. It works just fine on my test forum.


As for global value for the current user, {$mybb->user['postnum']} should also be fine, you don't need a query...
This code works great tahnks very much. <if $postnum >= 10 then>Show</if>

{$mybb->user['postnum']} in member template returns 1

Is there a some kind of global value for:



['reputation']
['referrals'] 
Just print_r the whole $mybb->user object and see what variables are available where you hook.
Pages: 1 2 3 4