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: 391
  • Total: 391

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

Thumbs on in the recent images block are set at max 100 pixels.  ;)

Quote from: Freddy on July 08, 2010, 08:06:32 PM

Do you want them to be able to vote from the front page - considering they will not be seeing them full size ?  It's also easier for me if you only show the smaller images as an enticer and a bar showing votes so far, without the option to vote.

Each image could also be a simple link to the topic.


I think the mod does give the function of voting from front page, but if you don't think it's possible, then don't worry.  O0

Freddy

It's possible, but I figure people are not going to make a choice without seeing the full size image.  So it would save me having to mess around with forms and submits.  ;)

lurkalot

At least Freddy's behaving himself, not once have I seen him in the arcade, lol...  :D

Freddy, if you want to see exactly what the poll does now on the front page, I'll grant you admin rights, then you will be able to see it.  O0

Freddy

It's okay I have it set up on my test forum at the moment, so I can see what it's doing.  Thanks anyway :)

lurkalot

Quote from: Freddy on July 08, 2010, 08:26:56 PM
It's okay I have it set up on my test forum at the moment, so I can see what it's doing.  Thanks anyway :)

Cool.  O0

Freddy

Can you try this out and see if it works alright :

// Set up the topic.
$pollResults = ssi_showPoll(11,'array');

// Images per row.
$imagesPerRow = 4;

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

$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 = 0;
}

echo '
<td style="width: 25%; text-align: center; padding: 1px">
<img ' , $image[0] , ' width="100" />
<br />
Member : ' , strip_tags($pollItem['option']) , '
<br />
Votes : ' , $pollItem['votes'] , ' (' , $pollItem['percent'] , '%)
<br />
' , $pollItem['bar'] , '
</td>';
}

do
{
echo '
<td style="width: 25%">
</td>';

$imageCount++;
} while ($imageCount +1 < $imagesPerRow);

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


This is what it looks like here...

lurkalot

Freddy thanks,

I couldn't get it to work to start with, then I realised that IE8 was messing up the code when I use it to paste the code in.  Switched to firefox and it works fine.   Been having this problem for a few weeks.  Tried it with a couple of old polls, and it displays nicely.  O0

Looks like you can only view the poll, but none of the images are clickable to the poll post for voting.  I'm assuming this was by design?  Or is this purely because the voting is closed?

Freddy

No they are not click-able because it was late last night and I forgot !  Sorry about that  ::)

I'll will make it so when you click on any of the images it will take you to the poll page so they can vote.

I've heard a few people mention now that IE8 messes up the code, strange...

Freddy

#28
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.

Edit: Code removed - Hang on a bit, there's a bug with the table.  Back later...

Freddy

Sorted...

/////////////////////
// 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']) , '
<br />
Votes : ' , $pollItem['votes'] , ' (' , $pollItem['percent'] , '%)
<br />
' , $pollItem['bar'] , '
</td>';
}

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

$imageCount++;
}

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

This website is proudly hosted on Crocweb Cloud Website Hosting.