Embedded Poll Hack v1.1 by Ianomed, a request from http://www.theadminzone.com/forums/index.php?t=6563
It's a simple addition to showthread.php, and two template mods (showthread + postbit[legacy])
What it does is embed a poll in the first post, rather than show it at the top of the thread. On pages 2+ of course it'll show it at the top of the thread, since post 1 won't be displayed there.
See attached screenshot for an example, or check out http://www.startrek-online.net/community/index.php?t=479&page=1&pp=10&styleid=4
Works with and tested on vB 3.0.6
Changelog:
v1.1 - 30 January 2005 - Added support for hybrid+threaded mode
v1.0 - 24 January 2005 - Initial release
--- Install instructions ---
in showthread.php, find:
PHP Code:
################################################################################
####################### SHOW THREAD IN LINEAR MODE #############################
################################################################################
if ($threadedmode == 0)
{
below find:
PHP Code:
$post['musername'] = fetch_musername($post);
$post['islastshown'] = ($post['postid'] == $lastpostid);
$post['attachments'] = &$postattach["$post[postid]"];
if ($post['isdeleted'])
{
$template = 'postbit_deleted';
}
else
{
$template = 'postbit';
}
$postbits .= construct_postbit($post, $template);
replace with:
PHP Code:
$post['musername'] = fetch_musername($post);
$post['islastshown'] = ($post['postid'] == $lastpostid);
$post['attachments'] = &$postattach["$post[postid]"];
if ($post['isdeleted'])
{
$template = 'postbit_deleted';
}
else
{
$template = 'postbit';
}
// embedded poll
if ($poll && ($post['postcount'] == 1))
{
$post['pollresults']=$poll;
}
else
{
$post['pollresults']="";
}
// embedded poll end
$postbits .= construct_postbit($post, $template);
find:
PHP Code:
################################################################################
################ SHOW THREAD IN THREADED OR HYBRID MODE ########################
################################################################################
}
else
{
below find:
PHP Code:
// init
$postcount = 0;
$postbits = '';
$saveparsed = '';
$jspostbits = '';
foreach (explode(',', $cache_postids) AS $id)
{
// get the post from the post array
if (!isset($postarray["$id"]))
{
continue;
}
$post = $postarray["$id"];
$post['musername'] = fetch_musername($post);
$post['postcount'] = ++$postcount;
$parsed_postcache = array('text' => '', 'images' => 1);
$template = iif($post['isdeleted'], 'postbit_deleted', 'postbit');
$post['attachments'] = &$postattach["$post[postid]"];
$bgclass = 'alt2';
if ($threadedmode == 2) // hybrid display mode
{
$postbits .= construct_postbit($post, $template);
}
else // threaded display mode
{
$postbit = construct_postbit($post, $template);
replace with:
PHP Code:
// init
$postcount = 0;
$postbits = '';
$saveparsed = '';
$jspostbits = '';
foreach (explode(',', $cache_postids) AS $id)
{
// get the post from the post array
if (!isset($postarray["$id"]))
{
continue;
}
$post = $postarray["$id"];
$post['musername'] = fetch_musername($post);
$post['postcount'] = ++$postcount;
$parsed_postcache = array('text' => '', 'images' => 1);
$template = iif($post['isdeleted'], 'postbit_deleted', 'postbit');
$post['attachments'] = &$postattach["$post[postid]"];
// embedded poll
if ($poll && ($post['postcount'] == 1))
{
$post['pollresults']=$poll;
}
else
{
$post['pollresults']="";
}
// embedded poll end
$bgclass = 'alt2';
if ($threadedmode == 2) // hybrid display mode
{
$postbits .= construct_postbit($post, $template);
}
else // threaded display mode
{
$postbit = construct_postbit($post, $template);
save and close file.
open template SHOWTHREAD, find (near the top):
replace with: (this makes sure the poll will appear at the top on pages 2+, as per default, but hides it on page 1)
PHP Code:
<if condition="$pagenumber > 1">
$poll
</if>
finally open template postbit or postbitlegacy (depending on your preferences), find:
PHP Code:
<!-- message -->
<div>$post[message]</div>
<!-- / message -->
replace with:
PHP Code:
<!-- message -->
<div>$post[message]<!-- embedded poll -->
<if condition="$post[pollresults]">
<br />
<br />
$post[pollresults]
</if><!-- embedded poll end -->
</div>
<!-- / message -->
unless of course you want it beneath (possible) attachments, but above the signature, etc etc., then you'd place it there