Displaying poll from PHPBB

Having trouble installing serendipity?
Post Reply
Guest

Displaying poll from PHPBB

Post by Guest »

I am currently using the FetchAll script to pull a poll from my PHPBB to display on my homepage. I'd like to be able to show this poll in the sidebar of my blog. Seems like I probably need a plugin, but my php skills are fairly nonexistent so any help is much appreciated.

Here's the code that FetchAll needs:

Code: Select all

<?php
//
// This path points to the directory where phpBB is installed. Do
// not enter an URL here. The path must end with a trailing
// slash.
//

$phpbb_root_path = './forum/';

define ('IN_PHPBB', true);

if (!file_exists($phpbb_root_path . 'extension.inc'))
{
    die ('<tt><b>phpBB Fetch All:</b>
          $phpbb_root_path is wrong and does not point to your forum.</tt>');
}

//
// phpBB related files
//

include_once ($phpbb_root_path . 'extension.inc');
include_once ($phpbb_root_path . 'common.' . $phpEx);
include_once ($phpbb_root_path . 'includes/bbcode.' . $phpEx);

//
// Fetch All related files
//
include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/polls.' . $phpEx);
//
// start session management
//

##$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);

// fetch a poll
$poll = phpbb_fetch_poll(2);
//
// disconnect from the database
//

phpbb_disconnect();?>
And then the code to display the poll itself:

Code: Select all

<?php if ($poll) { ?>
        
        <table width="150" cellpadding="1" cellspacing="1" border="0" style="border: 2px solid #36558C">
          <tr> 
            <td height="32" bgcolor="#FFFF66"> 
              <div align="center"><strong>What's Goin' On?</strong></div></td>
          </tr>
          <tr> 
            <td width="100%" align="left" bgcolor="#FFFFFF"> <font color="#000033"> 
              <?php if (!$poll) { ?>
              <strong><font size="-1" face="Arial">No poll at the moment.</font></strong> 
              <?php } else { ?>
              <strong><font size="-1" face="Arial"><?php echo $poll['vote_text']; ?></font></strong> 
               </font> <form method="post" action="<?php echo append_sid($phpbb_root_path . 'posting.php?t=' . $poll['topic_id']); ?>">
                <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber7">
                  <tr> 
                    <td width="100%"> <table>
                        <font color="#000033" face="Arial"> 
                        <?php for ($i = 0; $i < count($poll['options']); $i++) { ?>
                        </font> 
                        <tr> 
                          <td> <font color="#000033"> 
                            <input type="radio" name="vote_id" value="<?php echo $poll['options'][$i]['vote_option_id']; ?>">
                            </font></td>
                          <td> <font color="#000033"><font size="-1" face="Arial"><?php echo $poll['options'][$i]['vote_option_text']; ?></font> 
                            </font></td>
                        </tr>
                        <?php } ?>
                      </table></td>
                  </tr>
                  <tr> 
                    <td> </td>
                  </tr>
                  <tr> 
                    <td width="100%" height="30"> <p align="center"> <font color="#000033"> 
                        <input type="submit" class="mainoption" name="submit" value="Vote">
                        </font></td>
                  </tr>
                </table>
                <input type="hidden" name="topic_id" value="<?php echo $poll['topic_id']; ?>">
                <input type="hidden" name="mode" value="vote">
                <?php } ?></font>
                <font color="#000033"></font></font></form></td>
          </tr>
        </table>
        <?php } ?>
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Displaying poll from PHPBB

Post by garvinhicking »

You can try to use the serendipity_event_externalphp plugin to include foreign PHP scripts in a sidebar? Save your code as "phpbb.inc.php" and make that be included in the config of the PHP plugin.

If it works depends much on the included code, and how cleanly it was written and if it works without global variables, and if it opens and closes DB connections properly.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Guest

Post by Guest »

Well, I haven't had any luck with the external php plugin so I decided to give the url nugget plugin discussed HERE a try. I created a page that includes only the poll script and then used the url nugget plugin to call that file. This actually works except for the fact that it greatly increases the size of the radio button field so much that it distorts the size of the sidebar. Any ideas why this might be happening?

The poll file can be seen HERE

And inline in the blog HERE
Guest

Post by Guest »

Replying to myself... I found the problem... it was an error in the CSS.
Post Reply