MyBB Community Forums

Full Version: Thread Count
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello

I want integrate or show the thread number in the user profile (index).

Actually i show the total user post using this line :

{$mybb->user['postnum']}

I wanna now if it's possible to do the same thing with post ?

Thank for help
Then surely it would be

{mybb->user['threadnum']}

I'm not too sure how the thread number is expressed in MyBB though. But I can't imagine it to be much different from that, they obviously want to keep it simple.
(2010-12-20, 07:31 PM)UndiscoveredTalent Wrote: [ -> ]Then surely it would be

{mybb->user['threadnum']}

I'm not too sure how the thread number is expressed in MyBB though. But I can't imagine it to be much different from that, they obviously want to keep it simple.

No, this would not fetch the "thread's number".

@OP: You would definitely need a plugin. I'll try to code this tomorrow.
Yes, the first thing i try is : {mybb->user['threadnum']}
But this not work.

Thank you Yaldaram, i guest that you'll add a function in function.php ?
I making a plugin right now Wink
Thank You man Smile
(2010-12-20, 08:34 PM)Yaldaram Wrote: [ -> ]Completed: http://yaldaram.com/showthread.php?tid=61 Smile

That's not how you should do it. If I create 10,000 threads, it will be counting all those threads. Plus, it does not even use MySQL to count the rows, you're running a MySQL SELECT query and counting all rows returned by the query when you could just run a COUNT query.

You should first query all users into an array, and then count the threads for each user - ON INSTALLATION.

Then, you should add a hook to the insert thread action and increase the counter whenever someone creates a thread - and decrease it whenever a thread gets deleted.

I do this on My Achievements because it also requires a "threads counter" and ZiNgA BuRgA made a plugin for 1.2 which did this (the way I mentioned above) and I remember someone upgrading it to 1.4 but I can't seem to find it right now.

This is way less resource consuming apart from the installation - you may need to separate users by 200 for example and ask the admin to Continue - MyBB does this on the Rebuild & Recount page for example.
I've just take a quick test with the plugin;
by making a thread -> thread counter increases
by deleting a thread -> thread counter decreases

I think its working fine and doesn't making a load on db. :\

Or I'll surely wants help from you guys (who are older than me in mybb plugin authoring) to give me suggestions on sql queries, because I'm in just a beginning in php Smile
(2010-12-20, 08:59 PM)Yaldaram Wrote: [ -> ]I've just take a quick test with the plugin;
by making a thread -> thread counter increases
by deleting a thread -> thread counter decreases

I think its working fine and doesn't making a load on db. :\

Or I'll surely wants help from you guys (who are older than me in mybb plugin authoring) to give me suggestions on sql queries, because I'm in just a beginning in php Smile

No, that's not the problem Yaldaram. The problem is that the query may take more processing power than this feature should require - and it's possible to write it in a way which requires a lot less processing power.

For example, if there's a user with 10,000 threads on a website and 100 users decide to open their profile, the query will query 10,000 threads * 100 users which will require a lot of resources unnecessarily.

Get me? My suggestion above is for you to re-write the plugin in order to use less resources Smile
Pages: 1 2