TinyPortal

Development => Support => Topic started by: den15b on June 04, 2009, 02:15:57 AM

Title: poll display in block on frontpage
Post by: den15b on June 04, 2009, 02:15:57 AM
Hey & G'day

I am new here

I was just wondering if it was possible to display the results after someone has voted in a poll, let me alaborate a little, I have a front page poll in a block, when a guest votes, the poll disapears (the block stays, though reduced), obviously because I have set up the polls to only allow 1 vote per user, but what I want it to do is, once someone has voted, I want the block to show the results of the poll, rather than an empty block everytime they visit my site, is this possible?

Regards Denis
Title: Re: poll display in block on frontpage
Post by: Renegd98 on June 04, 2009, 03:52:11 AM
den15b,

Welcome to TP.

Please read the Posting Guidelines.html (http://www.tinyportal.net/index.php/topic,581) and provide the requested information so that we may help you more with your isseu.
Title: Re: poll display in block on frontpage
Post by: den15b on June 04, 2009, 07:24:00 AM
Link to my site: http://www.videohelp1.com
SMF version: SMF ver. 1.1.9
TP version: TP v1.0 beta 4
Theme name and version: Default core theme
Browser Name and Version: IE/7
Mods installed: TinyPortal only 
Related Error messages: N/A

If you vote on the front page, you will see that the poll disapears when you return to the home page, I was hoping it would display the results even if you leave the site & return, the poll results would still be there, but at the moment, the poll just disapears with the block being reduced.

Thankyou

Regards Denis
Title: Re: poll display in block on frontpage
Post by: ZarPrime on June 04, 2009, 01:52:32 PM
Hello den15b,

When I visit the site the Poll Block on the right is empty, no chance to vote first.  Please post the code you are using for this block so that we can try it on our own test sites and perhaps one of our coders can tell you what is the matter with it.

ZarPrime
Title: Re: poll display in block on frontpage
Post by: den15b on June 04, 2009, 02:49:39 PM
Thanks for the reply, so it is actualy worse than I thought, that means only 1 vote & it is closed from the front Page for every guest, would it be better if I granted someone temporary admin access? is this safe of me offering this?
Title: Re: poll display in block on frontpage
Post by: JPDeni on June 04, 2009, 03:27:27 PM
It would be better if you did what ZarPrime suggested and posted your code so we could take a look at it.

Please use the "code" tags -- the # button on the reply form -- around your code.
Title: Re: poll display in block on frontpage
Post by: den15b on June 04, 2009, 03:46:48 PM
Ok, I will do that, but it is 1 in the morning here in oz, so i'll do it in the morning, thankyou

Regards Denis
Title: Re: poll display in block on frontpage
Post by: den15b on June 05, 2009, 04:08:24 AM
Um, where do I get the code from? sorry for the dumb question
Title: Re: poll display in block on frontpage
Post by: IchBin on June 05, 2009, 04:23:55 AM
Let me know if this helps. I think you're talking about a bug in the way SMF handles the polls.

http://www.tinyportal.net/index.php?topic=9623.0
Title: Re: poll display in block on frontpage
Post by: JPDeni on June 05, 2009, 05:36:40 AM
Quotewhere do I get the code from?

Go to the TP Admin area and edit that block. That's where the code is.
Title: Re: poll display in block on frontpage
Post by: den15b on June 05, 2009, 06:55:02 AM
[REMOVED]


hope this is right
Title: Re: poll display in block on frontpage
Post by: JPDeni on June 05, 2009, 01:39:43 PM
No.

Do you remember what you did when you created the block? Tell us what you did to make the block you have.
Title: Re: poll display in block on frontpage
Post by: den15b on June 05, 2009, 02:07:22 PM
Ok,
I went to the TinyPortal admin
Then I clicked on "Panels and Blocks"
Then I clicked "Add right block"
Then I selected type "Forum/SSI Functions" / Most recent Poll
Status is On
Choose your membergroups that will able to see this block, to "All"
Choose where the block should appear, to "Frontpage"



Did i get it right this time
Title: Re: poll display in block on frontpage
Post by: JPDeni on June 05, 2009, 02:47:00 PM
Yes. :)

You're using the SSI function. (There are other ways to display a poll than using SSI.)

That seems to have a bug in it, as mentioned by IchBin.
Title: Re: poll display in block on frontpage
Post by: den15b on June 05, 2009, 03:10:23 PM
Quote(There are other ways to display a poll than using SSI.)

OK, do you mind telling me the other ways please

Denis
Title: Re: poll display in block on frontpage
Post by: ZarPrime on June 05, 2009, 04:17:13 PM
Hi den15b,

The reason this is not doing what you want it to do is that the php ssi_recentPoll function allows you to vote but it doesn't display the results.

On my test site, which is http://talesofthehavenexpanse.com/smf1test/index.php, I just added this php block to show the most recent polls in boards 1 and 2.  You must be logged in to vote (this is a security feature, in other words Guests can't vote) but since guests can view the polls, you will be able to see both polls in the block in the right panel.

In order to do this, I used the block code snippet shown here ...
http://www.tinyportal.net/index.php/topic,12807.msg106401.html#msg106401

I changed the last 2 lines in the code to this ...


// display most recent poll from board number 1 and 2
tp_showPoll(null,'echo',1);
echo '<br /><hr />';
tp_showPoll(null,'echo',2);


This allows me to show the most recent poll from both boards.  I voted in the poll in board #1 (the string poll), but not in the poll for board #2 (the dog poll).  If you were allowed to be logged in, you would be able to vote in the second poll right from the block as there would be a submit button below that one.  Once you voted, ths view would change to show the results in the bottom poll just like it is shown for the top poll.

Hope this helps,
ZarPrime

EDIT: I just added a 3rd poll in a 3rd board on my test site and added another line to the bottom of the block code to get the poll in that board.  If you are logged in and haven't voted in any of the polls that are up there, the submit button will be shown for those polls until you vote.  See pic below ...
Title: Re: poll display in block on frontpage
Post by: den15b on June 05, 2009, 04:59:11 PM
Thanks for that, I will try it, by the way, I want to let guests vote as well, any chance of that happening

Regards Denis
Title: Re: poll display in block on frontpage
Post by: ZarPrime on June 05, 2009, 05:06:49 PM
Quote from: den15b on June 05, 2009, 04:59:11 PM
I want to let guests vote as well, any chance of that happening

No, no chance, as far as I can tell.  Why in the world would you want to allow non-members to vote?  Isn't it a goal to get people to be a member of your forum.  Voting is and should be a privelage for members, not for guests.

BTW, it appears that this code will not allow you to vote from the block if you have more than 1 poll showing in the block.  Showing the most recent poll period may be a limitation of the code.  I'll have to look at this later and see if anything could be done about that, or perhaps one of our coders can take a look at it and see if anything can be done about that.

ZarPrime
Title: Re: poll display in block on frontpage
Post by: den15b on June 05, 2009, 05:34:25 PM
QuoteBTW, it appears that this code will not allow you to vote from the block if you have more than 1 poll showing in the block.

Thats Ok with me, I only want 1 poll showing at a time

So no chance with the guest being able to vote, I was hoping they could vote, but not to worry, I have tried that code out & it works perfect, thankyou for your time

Denis
Title: Re: poll display in block on frontpage
Post by: ZarPrime on June 05, 2009, 05:57:22 PM
I don't know of any way to allow guests to vote for this reason ...

How would the software know that a guest has already voted and keep them from voting another 50 times if it didn't register their usernames in the database that they already voted?  I suppose it could be done with IP addresses but then a guest who has access to dynamic IP addresses could still vote multiple times.  I don't think this is something I'd want to see.

Marked solved.

ZarPrime
Title: Re: poll display in block on frontpage
Post by: Lesmond on June 05, 2009, 08:55:54 PM
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
Title: Re: poll display in block on frontpage
Post by: den15b on June 06, 2009, 03:20:52 AM
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
Title: Re: poll display in block on frontpage
Post by: WillyP on June 07, 2009, 02:50:26 PM
Thanks for this code, I have it up and running at PlanetDescent.net (http://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
Title: Re: poll display in block on frontpage
Post by: JPDeni on June 07, 2009, 03:02:53 PM
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."
Title: Re: poll display in block on frontpage
Post by: WillyP on June 07, 2009, 03:09:16 PM
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...  ;)
Title: Re: poll display in block on frontpage
Post by: JPDeni on June 07, 2009, 04:20:07 PM
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;
Title: Re: poll display in block on frontpage
Post by: WillyP on June 07, 2009, 06:34:04 PM
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.
Title: Re: poll display in block on frontpage
Post by: JPDeni on June 07, 2009, 06:37:12 PM
That would be the tp_showPoll function. That's where I got the code, too.
Title: Re: poll display in block on frontpage
Post by: WillyP on June 07, 2009, 09:40:25 PM
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...
Title: Re: poll display in block on frontpage
Post by: JPDeni on June 07, 2009, 11:29:24 PM
If you still have problems, post your code so I can see what's wrong.
Title: Re: poll display in block on frontpage
Post by: WillyP on June 09, 2009, 01:44:13 AM
Would you prefer I start a new thread?
Title: Re: poll display in block on frontpage
Post by: JPDeni on June 09, 2009, 01:45:54 AM
Yeah, probably best since this one is marked solved.
Title: Re: poll display in block on frontpage
Post by: WillyP on June 09, 2009, 02:24:56 AM
ok... http://www.tinyportal.net/index.php/topic,29904.msg238326.html#msg238326