vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Embedded Poll (like UBB.Threads) (https://vborg.vbsupport.ru/showthread.php?t=75000)

Ianomed 01-23-2005 10:00 PM

Embedded Poll (like UBB.Threads)
 
Embedded Poll Hack v1.1 by Ianomed, a request from TheAdminZone

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 this poll

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):
PHP Code:

$poll 

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 :)

yoyoyoyo 01-24-2005 12:39 PM

cool idea! I will check it out later! Thanks for sharing.

Ianomed 01-24-2005 12:42 PM

My pleasure :)

nexialys 01-24-2005 12:46 PM

/me check and please!!

Ianomed 01-24-2005 12:57 PM

Hey Nexy, good to see you around :)
And nice to see you're pleased with the hack.

nexialys 01-24-2005 01:04 PM

Quote:

Originally Posted by Ianomed
Hey Nexy, good to see you around :)
And nice to see you're pleased with the hack.

hum.. around ?!... you missed me ?! ;) ;)

yeah, i just applyed the hack, and it's good... i thought to recode it a bit, but it's useless, you worked it out well.

btw, in showthread.php there is 3 "$postbits .= construct_postbit($post, $template);" ... specify what is the one to edit... ;) -- or guys, edit the three, you will have the same setting for all kind of displays (threaded as well)

Ianomed 01-24-2005 01:12 PM

lol, indeed. I've been rather busy with work, enjoying a short breather now. As such not been around here much.

About the 3 sequences, I've never used threaded/hybrid mode on any board whatsoever, so it kinda escaped my attention to make it tick for those as well. *whistles*

I'll post an update to include instructions for it shortly, thanks for pointing it out :D

Guy G 01-24-2005 04:42 PM

Thats fantasitc.
Doing it now for sure.

Ianomed 01-24-2005 04:45 PM

thanks :)
keep in mind it doesn't work for threaded and hybrid mode, yet.
I'm posting up a revised version that includes instructions for getting that to work too.
Thusfar all admins I asked never use those modes, but you never know ;)

Skyline_GT 01-24-2005 06:05 PM

nice hack... Might install it later.
Thanks.


All times are GMT. The time now is 11:02 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01178 seconds
  • Memory Usage 1,800KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (10)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete