TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 04, 2024, 08:09:03 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,178
  • Total Topics: 21,220
  • Online today: 82
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 84
  • Total: 84

[Block] Polls for TP/SMF - and associated SSI hack

Started by Thurnok, October 21, 2006, 07:21:13 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Thurnok

Someone asked me how to put multiple polls in the same block.  Here's a block example for that, and some other info for those that may not have seen it elsewhere or where it may have gotten lost in the shuffle.

To create your (multi-)Poll block, create a phpblock.  In it place the following code - replicate as required:
ssi_showPoll(70.0);
echo '<br /><hr />';
ssi_showPoll(135.0);
echo '<br /><hr />';
ssi_showPoll(121.0);
echo '<br /><hr />';
ssi_showPoll(122.0);

Replace the numbers in parenthesis with the actual number of your poll's post.  This example shows 4 polls, only place as many as you need/have in the block obviously. ;)

In order for your members to actually vote from the Poll block, you need the SSI hack found here.

And you should include the SSI hack below to prevent the bars from breaking your theme borders.

This hack originally comes courtesy of another TP Team member (Raysr) and is highly recommended if you plan to have a Poll block as left/right.  I've updated it to include the fix for SMF 1.1RC3 as well as some fixes to the original 1.1RC2 version.  This one also sets each option name to italics, but only in the results list.

Edit SSI.php
[FIND ALL OCCURRANCES]
$barWide = $bar == 0 ? 1 : floor(($bar * 5) / 3);

[REPLACE ALL WITH]
$barWide = $bar == 0 ? 1 : floor(($bar * 5) / 6);

What to do next depends on the version of SMF you have installed.  Please use only the one for your version.

For SMF 1.1RC2 ONLY!
[FIND]
echo '
<tr>
<td align="left" valign="top"><b>', $option['option'], '</b></td>
<td align="left">', $option['bar'], ' ', $option['votes'], '(', $option['percent'], '%)</td>
</tr>';

[REPLACE WITH]
echo '
<tr>
<td colspan="2" align="left" valign="top" style="font-style: italic"><b>', $option['option'], '</b></td>
</tr>
<tr>
<td align="left">', $option['bar'], '<td>
<td align="left">', $option['votes'], '(', $option['percent'], '%)</td>
</tr>';



For and tested with SMF 1.1RC3, 1.1, 1.1.1 - 1.1.6 ONLY!
[FIND]
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>
<td align="left">', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';

[REPLACE WITH]
echo '
<tr>
<td colspan="2" align="left" valign="top" style="font-style: italic">', $option['option'], '</td>
</tr>
<tr>
<td align="left">', $option['bar'], '</td>
<td align="left">', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';


EDIT: Edited to fix one broken link... Ken. (thanks Ken.) :)

EDIT: Updated supported versions... T


ckale

Changing this code has solved my portal's visual problem with bar graphics.  :up:

$barWide = $bar == 0 ? 1 : floor(($bar * 5) / 6);



Thurnok


Wish

What about for version 1.1.1? What do we do then?

IchBin

As far as I can tell it should still work. Did you try it?

Thurnok

Version 1.1.1 should be able to use the same hack as 1.1RC3.  I haven't validated yet, but if the search text for 1.1.1 is identical to 1.1RC3, then you can pretty much count on the replace text being identical.

I'll validate this tomorrow sometime.

Thurnok

Validated.  SMF 1.1 and 1.1.1 has identical code as that of 1.1RC3 for this particular area.  I tested this in both and works as designed.

funxlab

Thurnok !
I just installed your code on my fresh SMF and TP installation. As it is new forum, I knew post number of my poll. But how can I find out post number of any future polls ?
I will have to change phpbloc every time I want a specfic poll to appear on TP right?
Regards,
Jim

Thurnok

Yes, when you make a new poll that you want displayed in a TP block on your frontpage, you will need to edit the php block and add the new post info to it.  You can have multiple polls within the same block as you can see from the example.  So you can add as many as you like, though I wouldn't recommend adding too many because that will make your page quite long.  You can of course replace previous ones with the new ones simply by replacing the post number.