(2019-08-07, 09:38 AM)[ExiTuS] Wrote: [ -> ]The following code change fits your needs:
$sql = "SELECT t.lastposteruid, t.tid, t.subject, t.prefix, t.lastpost, t.fid, t.views, t.replies, u.usergroup, u.displaygroup, u.username, u.uid, p.prefix, p.displaystyle
FROM ".TABLE_PREFIX."threads t
INNER JOIN ".TABLE_PREFIX."users u ON (u.uid=t.lastposteruid)
INNER JOIN ".TABLE_PREFIX."threadprefixes p ON (p.pid=t.prefix)
...
- Add "t.prefix", "p.prefix", "p.displaystyle" to the SELECT statement.
- Add another "INNER JOIN ..." to get the prefix from table threadprefixes.
That's all SQL.
Then make the template variables available - choose any name ( $tpl[...] ) you want to use for your template.
$tpl['prefix'] = $row['prefix']; # Just the plain text of the prefix
$tpl['prefix_style'] = $row['displaystyle']; # The formatted prefix styled in ACP
Now you can use the variable {$tpl['prefix_style']} in your template.
If you want to use prefixes in other widgets of this plugin, do the same change for according SQL.
[ExiTuS]
Hey Exitus,
I am trying to add this to "LastThreads", followed the same steps, but maybe it requires something else, or I did something wrong?
$sql = "SELECT t.uid, t.tid, t.subject, t.prefix, t.dateline, t.fid, u.usergroup, u.displaygroup, u.avatar, u.avatardimensions, u.username, u.uid, p.prefix
FROM ".TABLE_PREFIX."threads AS t
INNER JOIN ".TABLE_PREFIX."users AS u USING (uid)
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.tid DESC LIMIT ". (int)$this->getConfig('Limit_LastThreads') ."";
$result = $db->query($sql);
while ($row = $db->fetch_array($result))
{
$forumpermissions[$row['fid']] = forum_permissions($row['fid']);
if(isset($forumpermissions[$row['fid']]['canonlyviewownthreads']) && $forumpermissions[$row['fid']]['canonlyviewownthreads'] == 1 && $row['uid'] != $mybb->user['uid'])
{
continue;
}
$subject = $parser->parse_badwords(htmlspecialchars_uni($row['subject']));
$tpl['subject'] = (my_strlen($subject) > 30) ? my_substr($subject, 0, 30) . "..." : $subject;
$tpl['username'] = format_name($row['username'], $row['usergroup'], $row['displaygroup']);
$tpl['profilelink'] = build_profile_link($tpl['username'], $row['uid']);
$tpl['date'] = my_date('relative', $row['dateline']);
$tpl['subjectlink'] = get_thread_link($row['tid']);
$tpl['prefix'] = $row['prefix']; # Just the plain text of the prefix
$tpl['prefix_style'] = $row['displaystyle']; # The formatted prefix styled in ACP
$useravatar = format_avatar(htmlspecialchars_uni($row['avatar']), $row['avatardimensions'], my_strtolower($this->getConfig('AvatarWidth')));
(!$this->getConfig('Status_Avatar')) ? '' : eval("\$tpl['avatar'] = \"".$templates->get("topStats_LastThreadsAvatar")."\";");
eval("\$tpl['row'] .= \"" . $templates->get("topStats_LastThreadsRow") . "\";");
}
eval("\$topStats['LastThreads'] = \"" . $templates->get("topStats_LastThreads") . "\";");
}