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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,913
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 572
  • Total: 573
  • @rjen

poll display in block on frontpage

Started by den15b, June 04, 2009, 02:15:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lesmond

Just a side note here, guest can vote with SMF 2.0 RC1-1 if the option is set, but TP is not ready has yet for smf 2.0

den15b

#21
That's great news Lesmondâ„¢, I want to be able to allow guests to vote, & I am not really concerned if people vote more than once, after all, it's just for fun, but I have noticed that a site I frequent does have a front page poll that guests are allowed to vote on, it seems that when you vote as a guest & leave the site, apon returning the site has remembered you & will not allow you to vote again, however, I have worked out that if you delete your cookies, you can vote again, so obviously the poll vote uses the cookies to remember who you are, do you think that SMF2.0 or TP has/will implement this?

BTW, the block code snippet that ZarPrime linked me to is working great on my site, you bunch are really helpful & friendly around here, thankyou

Regards Denis

[edit] fix typos

WillyP

Thanks for this code, I have it up and running at PlanetDescent.net. Only one thing, I have the Poll set to view poll results only after voting, but I can view the poll results by logging out. ie, Guests can view results. Ideally, I would like guests to see the options, along with a message directing them to login or register to vote and view results.  It seems a little odd to view the results, then login and be told to vote before viewing the results...  :o

JPDeni

Then don't allow guests to view the block at all. You can create a "guest-only" block that says something like "If you would like to vote in polls, you must log in first."

WillyP

Thanks for the quick reply!

If there's no way to let guests see the options but not vote, then I will let everyone see the results before voting, so at least it's consistent. It's just for fun anyway...  ;)

JPDeni

You can change the code if you want. If you're using the tp_showPoll function,

before


else
{
echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2" class="smalltext"><a href="', $boardurl, '/index.php?topic=', $return['topic'], '"><b>', $return['question'], '</b></a></td>
</tr>';


add


elseif ($user_info['is_guest'])
{
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2" class="smalltext"><a href="', $boardurl, '/index.php?topic=', $return['topic'], '"><b>', $return['question'], '</b></a></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td colspan="2" align="left" valign="top" style="font-style: italic" class="smalltext">', $option['option'], '</td>
</tr>';
echo '
</table>
If you would like to vote in this poll, please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a>.';
}


Also, change


global $context;


to


global $context, $scripturl;

WillyP

Quote from: JPDeni on June 07, 2009, 04:20:07 PMIf you're using the tp_showPoll function,

OOPS, sorry, I posted in the wrong thread. I am using the code in a thread Zarprime linked to on page 2 of this thread.

JPDeni

That would be the tp_showPoll function. That's where I got the code, too.

WillyP

Ok... well, I tried your code above anyway and I got an empty block. I'll try again, maybe tomorrow. :up: I probably copied something wrong...

JPDeni

If you still have problems, post your code so I can see what's wrong.

This website is proudly hosted on Crocweb Cloud Website Hosting.