MyBB Community Forums

Full Version: Top stats prefix
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello i installed top stats plugin and it works fine ! 

But i would like add my prefix on the latest threads on index. 
i tried with Thread prefix plugin  but it does not work for top stats plugin


how can i do that ? 
Thanks in advance !
I think you're using this plugin, Top Stats:
https://community.mybb.com/mods.php?action=view&pid=269

To add prefixes to topics, you need to edit the $sql = "" in topStats.php file.
... widget_LastActiveThreads():
...
$sql = "SELECT t.lastposteruid, t.tid, t.subject, t.prefix, t.lastpost, t.fid, t.views, t.replies, u.uid, u.username, u.usergroup, u.displaygroup, u.lastvisit, u.lastactive, u.away, g.canviewwolinvis, p.prefix, p.displaystyle
FROM ".TABLE_PREFIX."threads t
INNER JOIN ".TABLE_PREFIX."users u ON (u.uid=t.lastposteruid)
INNER JOIN ".TABLE_PREFIX."usergroups g ON (u.usergroup = g.gid)
LEFT JOIN ".TABLE_PREFIX."threadprefixes p ON (p.pid=t.prefix)
WHERE 1=1 {$tpl['ignore_forums']} {$unapproved_where} {$permsql} AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
ORDER BY t.lastpost DESC LIMIT ". (int)$this->getConfig('Limit_LastActiveThreads') ."";
...
It is mandatory to also select "t.prefix" and add LEFT JOIN threadprefixes.

Good luck!

[ExiTuS]
Yes exactly i use this plugin,

So if i understood correctly , i have to add this line :
LEFT JOIN ".TABLE_PREFIX."threadprefixes p ON (p.pid=t.prefix)


and this word : 
t.prefix
in TopStats.php files ? 

because i did that and nothing change..

Thanks for your help
It is also mandatory to add "p.prefix" and "p.prefixstyle" (at the end of SELECT line)
$sql = "SELECT t.lastposteruid, t.tid, t.subject, t.prefix, t.lastpost, t.fid, t.views, t.replies, u.uid, u.username, u.usergroup, u.displaygroup, u.lastvisit, u.lastactive, u.away, g.canviewwolinvis, p.prefix, p.displaystyle
...
LEFT JOIN ".TABLE_PREFIX."threadprefixes p ON (p.pid=t.prefix)
...

I am sorry to forgot something...
Down below this SQL code, assign the variable to make it available for templates:
$tpl['prefix'] = $row['prefix'];
$tpl['prefix_style'] = $row['displaystyle'];

Now you can insert one of these prefix variables into the topStats template (Global Templates) at that position it should appear
- "prefix" will display plaintext only
- "prefix_style" will display the prefix in style formatted in ACP

Also mind both PHP chapters "LastActiveThreads" and "LastThreads" depending on which one your'e using and the templates for both as well (topStats_LastThreadsRow or topStats_LastActiveThreadsRow).

[ExiTuS]