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,966
  • Latest: safir45
Stats
  • Total Posts: 195,991
  • Total Topics: 21,323
  • Online today: 545
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 290
  • Total: 290

Poll images in front page block

Started by lurkalot, July 06, 2010, 11:22:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

lurkalot

Quote from: Freddy on July 09, 2010, 12:43:40 PM
Here you go.  I made the poll topic a variable now so it gets used for the links, so you just need to set $pollTopic instead.

I also added some padding to the bottom of each cell too so they space out a bit more.


Freddy, sorry for the delay getting back to you, been at work.  :(
 
Hey that's great and the new code works nicely.  8)  O0 http://cameracraniums.com/

Will I be able to see the votes before I vote, or only after?

Freddy

I'm not sure to be honest, try it out... lemme know...

lurkalot

Quote from: Freddy on July 09, 2010, 06:38:58 PM
I'm not sure to be honest, try it out... lemme know...

Thanks Freddy.  I'll set up a test poll and see.  O0

Edit:  OK set up a test poll.  it looks like the front page block is bypassing the following settings for the poll,

Show the poll's results to anyone.
Only show the results after someone has voted.
Only show the results after the poll has expired.

I'll wait until someone has voted to be sure.  ;)

lurkalot

Quote from: Freddy on July 09, 2010, 06:38:58 PM
I'm not sure to be honest, try it out... lemme know...

OK the guys have a poll running now.  You can see the votes before voting yourself.   :'(

Is there any way around this Freddy?

Freddy

Well I can mimic what SSI normally does... try this :

/////////////////////
// Set up the topic where the poll is.
$pollTopic = 11;

// Images per row.
$imagesPerRow = 4;
/////////////////////

$pollResults = ssi_showPoll($pollTopic,'array');

// Just a counter..
$imageCount = 0;

global $scripturl;

$patternImg = "/src=[\"']?([^\"']?.*(png|jpg|gif))[\"']?/i";

echo '
<table style="width: 100%">
<tr>';

foreach ($pollResults['options'] as $pollItem)
{
preg_match($patternImg, $pollItem['option'], $image);

$imageCount++;

if ($imageCount > $imagesPerRow)
{
echo '
</tr>
<tr>';

$imageCount = 1;
}

echo '
<td style="width: 25%; text-align: center; padding: 1px 1px 10px 1px;">
<a href="' , $scripturl , '?topic=' , $pollTopic , '">
<img ' , $image[0] , ' alt="Go Vote !" title="Go Vote !" border="0" width="100" />
</a>
<br />
Member : ' , strip_tags($pollItem['option']);

if (!$pollResults['allow_vote'])
{
echo '
<br />
Votes : ' , $pollItem['votes'] , ' (' , $pollItem['percent'] , '%)
<br />
' , $pollItem['bar'];
}

echo '
</td>';

}

while ($imageCount < $imagesPerRow)
{
echo '
<td style="width: 25%">
</td>';

$imageCount++;
}

echo '
</tr>
</table>';

lurkalot

Quote from: Freddy on July 13, 2010, 07:00:57 PM

Well I can mimic what SSI normally does... try this :


Woohoo, it works.  :D

Thank you Freddy, you're a star.  O0  I'm sure the guys will love this.

Freddy


lurkalot

 :-[ I spoke too soon.  All works well but now if you sign out you can see the votes.  ???

Freddy

Yeah it's the same with SSI.  I guess they figured that if they aren't a member then it might not matter if guests could see the results.  OR they never finished doing it properly...

We could hide the results from guests...would that do ?

lurkalot

Quote from: Freddy on July 14, 2010, 01:11:39 PM

We could hide the results from guests...would that do ?


That would be great, and would cure the problem O0  I'm assuming the poll images etc will still be visible etc, but just not the votes.

If worst comes to worst and as a last resort, I could always hide the block from guests.

Thanks again

Mick aka lurk

This website is proudly hosted on Crocweb Cloud Website Hosting.