Hi!
I wonder how to feature a single forum poll (or several single polls, or posts for that matter?) on the frontpage of TP?
If you pull up the ssi_examples.php file that is in the root of the forums, there are already several functions built that will display a poll.
However, these functions do not give you control over which poll to display, and they do not show the results of the poll once the user has voted.
I have already asked about being able to show polls on the front page as well. :)
8
Thanks - great :D!
Well, what about <?php ssi_showPoll($topic); ?> that shows up on that page ??? And how do I implement that code, if the correct one?, into a self made block?
To use the code you have, put it into a php block, but leave out the php tags.
ssi_showPoll($topic);
Thanks, that seemed to work... but I only got the poll result, not the voting form itself (I haven't voted in that poll myself)... Instead of the $topic string I just wrote the number of the topic, ssi_showPoll(684.0);
that is... Right or wrong...?
Wow, I must of messed something up the other day when I was trying it.. hehe
I only ever saw the poll questions, never the results.
However, I just tried it again, and it works very well. Although, it did break the column format (I had the poll in the right hand column), so I changed a couple of things in the ssi.php file to shorten the results bar. Around line 950, you will find a line that reads:
$barWide = $bar == 0 ? 1 : floor(($bar * 5) / 3);
I changed it to:
$barWide = $bar == 0 ? 1 : floor(($bar * 5) / 6);
And down around line 1000, I changed
<tr>
<td align="left" valign="top"><b>', $option['option'], '</b></td>
<td align="left">', $option['bar'], ' ', $option['votes'], '(', $option['percent'], '%)</td>
</tr>';
to
<tr>
<td align="left" valign="top"><b>', $option['option'], '</b></td>
</tr><tr>
<td align="left">', $option['bar'], ' ', $option['votes'], '(', $option['percent'], '%)</td>
</tr>';
Do you mean you could see the question as well as the result from the poll??? Over here I only see the result... Do you have an url to give me to check what it looks like over yours, before I get into that hacking php business and probably screw things up :uglystupid2: ?
Yes, I saw the poll until I voted and then saw the results.
I did it on a test installation on a local machine, so I cannot give you a URL (I am waiting on ver 0.8 before installing it on a live site, as I am also planning on upgrading to 1.1 RC2 at the same time...).
However, I did take a few screen shots of it that I can show you. Also, as a suggestion, instead of changing the function itself, it might be a better idea to copy it, and paste that copy at the bottom of the file (before the
?> that closes the file), and then just give it a slightly different name, and then make the changes I suggested in the new function.
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.ironcrown.com%2FICEforums%2Findex.php%3Faction%3Ddlattach%3Btopic%3D506.0%3Battach%3D16%3Bimage&hash=e3bb063337bd633ff98793bdf6830a1fdf754171)
| | (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.ironcrown.com%2FICEforums%2Findex.php%3Faction%3Ddlattach%3Btopic%3D506.0%3Battach%3D18%3Bimage&hash=a7bbca8b511758c661d390aff6d79f4dd89e8f8f)
|
Sry, the attachments didn't work over here but I may go ahead with the code changes anyway :D. Thanks!
EDIT: Well, I still just see the result from the poll - even when I'm logged out :tickedoff:... I wonder, may this be a 1.0.5 issue, or did I use the wrong code for that $topic argument to the function...???
Sure, the code change worked allright ;D! Thanks!
But, still 2 issues:
1) As before, I just can see the poll result :-\
2) The text font in the poll result is too big, overflooding the block.... Where may I change that (am using the default theme, btw)...?
Have you tried making a new poll and seeing if you can see that? It may be that for some reason the forum thinks you have voted already.
Look up at the code changes I posted above, specifically the second one where you add the closing and opening TR tags. The line above it is the text for each option, and the line below is the actual percentile bar.
So, you can change
echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>
<td align="left">', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';
to something like:
echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td><font size="-1"><b>', $return['question'], '</b></font></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="left" valign="top"><font size="-1"><b>', $option['option'], '</b></font></td>
</tr><tr>
<td align="left">', $option['bar'], ' ', $option['votes'], '<font size="-1"> (', $option['percent'], '%)</font></td>
</tr>';
echo '
<tr>
<td><font size="-1"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></font></td>
</tr>
</table>';
Note: You allready changed part of this with my earlier instructions & I forgot about the colspans of the sections above and below the poll options, that may be what was causing it to break the box as opposed to the text size.
Hmmm... How odd :uglystupid2:
This is what a did:
1. Created a new poll in my public forum, just as you told me to do, as admin. Chosed the option that all voters may change their choice...
2. It all turned up fine in the block as a previewed it and after been activating it, at least as I was logged in as admin... I saw the poll form, the submit button etc... :D
3. I logged out and as guest I then only saw the results :(...
4. Logged in as Global Moderator, I still just saw the results (had not voted) >:(
5. Logged out again and relogin as admin, then the poll form turned up again :o
6. As admin, i made a vote but the result from it didn't show up - just the form again with my chosen radiobutton as default :(
7. Logged out again and as guest and as Global Moderator it looked as before, just the poll results...
8: Relogin as admin and eventually the poll result shows up ^-^, so it almost worked as supposed to anyway ;). But now I no longer may change my vote, since the form is gone and there's no link in the box below the result for changing my vote :-\
Btw, I set up the block with permissions for everyone...
You might want to go into the SMF permissions and see what they are for the various user groups, that may be what is causing the issue...
The SSI function does have thing built upon the SMF permissions. So for this you not only have the TP permissions, but also the SMF permissions to deal with as well...
Yes, I see what you mean but I do think that it shouldn't be the case since I deliberately put the poll in a public board that anyone but guest may vote in...
BUT, I did a check about this anyway and here is the weird result:
1: If I login as a user (in this case Global Moderator) I still cannot vote in the portal block, just see the result (I haven't voted as a user).
2: I go to the forum an view the poll and there I may vote... and eventually the block changes as well as long as I view the vote form in the forum, I may vote in the block as well :o
3: But when I change view to the forum index in the forum, the block form once again disappears and just shows the result... :tickedoff:
4: If I enter the same board, or another board, then I may vote once again in the block ^-^ - no matter what board I'm viewing... :o
Hope this would give you a clue to hunt this issue down... :coolsmiley:?
I followed your advice for a code change in reply #10 (http://www.tinyportal.net/smf/index.php?topic=1930.msg15595#msg15595), and it worked so fine :).
But, to get the text within the block look somewhat clearer I changed the bold font for the $option line to italic instead (that way the title, options and results are easier to separate in a quick glance, I think)...
That is,
<td align="left" valign="top"><font size="-1"><i>', $option['option'], '</i></font></td>
BTW, I could make use of a "Change vote" link in the bottom of the poll result block... :buck2: I did not find any ssi code for that...
Quote from: misjka on January 05, 2006, 03:42:05 PM
Thanks, that seemed to work... but I only got the poll result, not the voting form itself (I haven't voted in that poll myself)... Instead of the $topic string I just wrote the number of the topic, ssi_showPoll(684.0);
that is... Right or wrong...?
Hmmm, now this whole thread is valid (again :() after the .86 upgrade... Is there something special to have in mind before I perform the modifications once again?