2019-10-20, 12:30 PM
Hi, I use this code to show latest posts on index.php and forumdisplay.php (with Patches):
Filename: forumdisplay.php
Search Pattern: $inline_edit_js = $clearstoredpass = '';
Insert After:
Filename: index.php
Search Pattern:
Insert After:
And these work.. now showthread, and here code don't appear:
Filename: showthread.php
Search Pattern:
Insert After:
Where am I wrong?
Thanks in advance
Maybe it depends on where I add code (Search Pattern), for example if I add code after this in showthread.php:
Latest posts appear, but title of the post in showthread not..
Filename: forumdisplay.php
Search Pattern: $inline_edit_js = $clearstoredpass = '';
Insert After:
$query = $db->query("
SELECT t.tid, t.fid, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, u.username, lp.avatar AS lpavatar
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
LEFT JOIN ".TABLE_PREFIX."users lp ON (lp.uid=t.lastposteruid)
WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.fid NOT IN ('170','121','132','160','144','119','148','149')
ORDER BY t.lastpost DESC
LIMIT 0, 10
");
while($thread = $db->fetch_array($query))
{
$forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);
// Make sure we can view this thread
if($forumpermissions[$thread['fid']]['canview'] == 0 || $forumpermissions[$thread['fid']]['canviewthreads'] == 0 || (isset($forumpermissions[$thread['fid']]['canonlyviewownthreads']) && $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid']))
{
continue;
}
$lastpostdate = my_date('relative', $thread['lastpost']);
// Don't link to guest's profiles (they have no profile).
if($thread['lastposteruid'] == 0)
{
$lastposterlink = $thread['lastposter'];
}
else
{
$lastposterlink = build_profile_link($thread['lastposter'], $thread['lastposteruid']);
}
if($thread['lpavatar'])
{
$thread['lpavatar'] = htmlspecialchars_uni($thread['lpavatar']);
}
else
{
$thread['lpavatar'] = $mybb->settings['bburl']."/images/avatars/omaggi.jpg"; $thread['avatardimensions'] = "44|44";
}
if($thread['avatar'])
{
$thread['avatar'] = htmlspecialchars_uni($thread['avatar']);
}
else
{
$thread['avatar'] = $mybb->settings['bburl']."/images/avatars/omaggi.jpg"; $thread['avatardimensions'] = "44|44";
}
$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
$thread['fullsubject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
$thread['threadlink'] = get_thread_link($thread['tid']);
$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
$thread['forumlink'] = get_thread_link($thread['fid']);
$thread['forumname'] = $forum_cache[$thread['fid']]['name'];
eval("\$index_ultimi_ultimi .= \"".$templates->get("index_ultimi_ultimi")."\";");
}
eval("\$index_ultimi = \"".$templates->get("index_ultimi")."\";");
Filename: index.php
Search Pattern:
if($bdaycount > 0 || $hiddencount > 0)
{
eval('$birthdays = "'.$templates->get('index_birthdays').'";');
}
}
Insert After:
$query = $db->query("
SELECT t.tid, t.fid, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, u.username, lp.avatar AS lpavatar
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
LEFT JOIN ".TABLE_PREFIX."users lp ON (lp.uid=t.lastposteruid)
WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.fid NOT IN ('170','121','132','160','144','119','148','149')
ORDER BY t.lastpost DESC
LIMIT 0, 10
");
while($thread = $db->fetch_array($query))
{
$forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);
if($forumpermissions[$thread['fid']]['canview'] == 0 || $forumpermissions[$thread['fid']]['canviewthreads'] == 0 || (isset($forumpermissions[$thread['fid']]['canonlyviewownthreads']) && $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid']))
{
continue;
}
$lastpostdate = my_date('relative', $thread['lastpost']);
if($thread['lastposteruid'] == 0)
{
$lastposterlink = $thread['lastposter'];
}
else
{
$lastposterlink = build_profile_link($thread['lastposter'], $thread['lastposteruid']);
}
if($thread['lpavatar'])
{
$thread['lpavatar'] = htmlspecialchars_uni($thread['lpavatar']);
}
else
{
$thread['lpavatar'] = $mybb->settings['bburl']."/images/avatars/omaggi.jpg"; $thread['avatardimensions'] = "44|44";
}
if($thread['avatar'])
{
$thread['avatar'] = htmlspecialchars_uni($thread['avatar']);
}
else
{
$thread['avatar'] = $mybb->settings['bburl']."/images/avatars/omaggi.jpg"; $thread['avatardimensions'] = "44|44";
}
$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
$thread['fullsubject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
$thread['threadlink'] = get_thread_link($thread['tid']);
$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
$thread['forumlink'] = get_thread_link($thread['fid']);
$thread['forumname'] = $forum_cache[$thread['fid']]['name'];
eval("\$index_ultimi_ultimi .= \"".$templates->get("index_ultimi_ultimi")."\";");
}
eval("\$index_ultimi = \"".$templates->get("index_ultimi")."\";");
And these work.. now showthread, and here code don't appear:
Filename: showthread.php
Search Pattern:
if($thread['visible'] == -1 )
{
$thread_deleted = 1;
}
$plugins->run_hooks("showthread_end");
eval("\$showthread = \"".$templates->get("showthread")."\";");
output_page($showthread);
}
Insert After:
$query = $db->query("
SELECT t.tid, t.fid, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, u.username, lp.avatar AS lpavatar
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
LEFT JOIN ".TABLE_PREFIX."users lp ON (lp.uid=t.lastposteruid)
WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.fid NOT IN ('170','121','132','160','144','119','148','149')
ORDER BY t.lastpost DESC
LIMIT 0, 10
");
while($thread = $db->fetch_array($query))
{
$forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);
if($forumpermissions[$thread['fid']]['canview'] == 0 || $forumpermissions[$thread['fid']]['canviewthreads'] == 0 || (isset($forumpermissions[$thread['fid']]['canonlyviewownthreads']) && $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid']))
{
continue;
}
$lastpostdate = my_date('relative', $thread['lastpost']);
if($thread['lastposteruid'] == 0)
{
$lastposterlink = $thread['lastposter'];
}
else
{
$lastposterlink = build_profile_link($thread['lastposter'], $thread['lastposteruid']);
}
if($thread['lpavatar'])
{
$thread['lpavatar'] = htmlspecialchars_uni($thread['lpavatar']);
}
else
{
$thread['lpavatar'] = $mybb->settings['bburl']."/images/avatars/omaggi.jpg"; $thread['avatardimensions'] = "44|44";
}
if($thread['avatar'])
{
$thread['avatar'] = htmlspecialchars_uni($thread['avatar']);
}
else
{
$thread['avatar'] = $mybb->settings['bburl']."/images/avatars/omaggi.jpg"; $thread['avatardimensions'] = "44|44";
}
$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
$thread['fullsubject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
$thread['threadlink'] = get_thread_link($thread['tid']);
$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
$thread['forumlink'] = get_thread_link($thread['fid']);
$thread['forumname'] = $forum_cache[$thread['fid']]['name'];
eval("\$index_ultimi_ultimi .= \"".$templates->get("index_ultimi_ultimi")."\";");
}
eval("\$index_ultimi = \"".$templates->get("index_ultimi")."\";");
Where am I wrong?
Thanks in advance
Maybe it depends on where I add code (Search Pattern), for example if I add code after this in showthread.php:
$classic_header = '';
if($mybb->settings['postlayout'] == "classic")
{
eval("\$classic_header = \"".$templates->get("showthread_classic_header")."\";");
}
Latest posts appear, but title of the post in showthread not..