2012-09-24, 02:43 AM
2012-09-24, 02:51 AM
Ok, here is the working code I was using when I first made this thread
<?php
define('IN_MYBB', 1); require "./global.php";
add_breadcrumb("Polls", "nlpolls.php");
// get forums user cannot view
$unviewable = get_unviewable_forums(true);
if($unviewable)
{
$unviewwhere = " AND fid NOT IN ($unviewable)";
}
$altbg = alt_trow();
$threadlist = '';
$query = $db->query("
SELECT t.*, u.username, u.displaygroup, u.avatar, u.usergroup, u.avatardimensions, f.name AS forumname, lp.avatar as lpavatar, t.username AS threadusername
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)
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=t.fid)
WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.poll > 0
ORDER BY t.lastpost DESC
LIMIT 0, 10"
);
while($thread = $db->fetch_array($query))
{
$lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
$lastposttime = my_date($mybb->settings['timeformat'], $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/default_avatar.gif"; $thread['avatardimensions'] = "45|45";
}
if($thread['avatar'])
{
$thread['avatar'] = htmlspecialchars_uni($thread['avatar']);
}
else
{
$thread['avatar'] = $mybb->settings['bburl']."/images/default_avatar.gif"; $thread['avatardimensions'] = "45|45";
}
if(my_strlen($thread['subject']) > 100)
{
$thread['subject'] = my_substr($thread['subject'], 0, 100) . "...";
}
$thread['subject'] = htmlspecialchars_uni($thread['subject']);
$thread['threadlink'] = get_thread_link($thread['tid']);
$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
$thread['username'] = $thread['threadusername'];
$threadstarter = build_profile_link($thread['username'], $thread['uid']);
$thread['profilelink'] = $thread['threadusername'];
eval("\$threadlist .= \"".$templates->get("portal_latestpolls_poll")."\";");
$altbg = alt_trow();
}
if($threadlist)
{
// Show the table only if there are threads
eval("\$nlpolls = \"".$templates->get("portal_latestpolls")."\";");
}
eval("\$html = \"".$templates->get("nintendolounge_polls")."\";");
output_page($html);
?>
2012-09-24, 02:55 AM
Try this:
<?php
define('IN_MYBB', 1); require "./global.php";
add_breadcrumb("Polls", "nlpolls.php");
// get forums user cannot view
$unviewable = get_unviewable_forums(true);
if($unviewable)
{
$unviewwhere = " AND fid NOT IN ($unviewable)";
}
$altbg = alt_trow();
$threadlist = '';
$query = $db->query("
SELECT t.*, u.username, u.displaygroup, u.avatar, u.usergroup, u.avatardimensions, f.name AS forumname, lp.avatar as lpavatar, t.username AS threadusername
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)
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=t.fid)
WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.poll > 0
ORDER BY t.lastpost DESC
LIMIT 0, 10"
);
/*******/
$pids = $polls = $votes = array();
while($pid = $db->fetch_field($query, 'poll'))
{
$pids[] = (int)$pid;
}
$query_p = $db->simple_select('polls', 'pid, numvotes', "pid IN ('".implode("','", $pids)."')");
while($poll = $db->fetch_array($query_p))
{
$polls[(int)$poll['pid']] = (int)$poll['numvotes'];
}
$query_p = $db->simple_select('pollvotes', 'pid', "pid IN ('".implode("','", $pids)."') AND uid='{$mybb->user['uid']}'");
while($vote = $db->fetch_field($query_p, 'pid'))
{
$votes[(int)$vote['pid']] = 1;
}
/*******/
while($thread = $db->fetch_array($query))
{
/*******/
$votes = 'This poll has '.my_number_format($polls[(int)$poll['pid']]).' votes.';
$mark = '';
if(isset($votes[(int)$thread['poll']]))
{
$mark = '<span title="You already voted for this poll.">*</span>';
}
/*******/
$lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
$lastposttime = my_date($mybb->settings['timeformat'], $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/default_avatar.gif"; $thread['avatardimensions'] = "45|45";
}
if($thread['avatar'])
{
$thread['avatar'] = htmlspecialchars_uni($thread['avatar']);
}
else
{
$thread['avatar'] = $mybb->settings['bburl']."/images/default_avatar.gif"; $thread['avatardimensions'] = "45|45";
}
if(my_strlen($thread['subject']) > 100)
{
$thread['subject'] = my_substr($thread['subject'], 0, 100) . "...";
}
$thread['subject'] = htmlspecialchars_uni($thread['subject']);
$thread['threadlink'] = get_thread_link($thread['tid']);
$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
$thread['username'] = $thread['threadusername'];
$threadstarter = build_profile_link($thread['username'], $thread['uid']);
$thread['profilelink'] = $thread['threadusername'];
eval("\$threadlist .= \"".$templates->get("portal_latestpolls_poll")."\";");
$altbg = alt_trow();
}
if($threadlist)
{
// Show the table only if there are threads
eval("\$nlpolls = \"".$templates->get("portal_latestpolls")."\";");
}
eval("\$html = \"".$templates->get("nintendolounge_polls")."\";");
output_page($html);
?>
2012-09-24, 02:58 AM
Nope, no threads appear with that code.
2012-09-24, 03:13 AM
May you provide us with temporary FTP access to your forum files? If so please do so here where only staff and yourself can view your threads. Please do add a link back to this thread in the OP as well.
2012-09-24, 03:45 AM
Done
2012-11-12, 08:09 AM
EDIT: Shouldn't have bumped this thread.
2013-01-04, 10:37 AM
how to choose one particular forum only?
2013-01-04, 07:04 PM
Depends on the code you are using.