The aim of this tutorial is to Change poll bar colors according to the percent of votes it received. This require to edit one template and one core file edit.
Open ./showthread.php and find;
Save the file.
Now Go to: ACP > Templates > Your theme's templates > Showthread templates > showthread_poll_resultbit > and find;
Now it'll look like this;
You may change these colors to suite your taste.
Now if you want to add these colors on Poll results page, then here is how;
Similarly open ./poll.php and find;
Now add the following code just Above it;
Now open ACP > templates > Your theme's templates > Poll templates > "polls_showresults_resultbit" template and find;
Open ./showthread.php and find;
$imagerowwidth = $imagewidth + 10;
and Add the following code just Beneath it; // Poll Votes Colors
if ($percent == 10 || $percent < 10 && $percent > 0)
{
$pollbg = '#FF0000';
}
elseif ($percent >= 11 && $percent < 20)
{
$pollbg = '#33CC33';
}
elseif ($percent >= 20 && $percent < 30)
{
$pollbg = '#FF33CC';
}
elseif ($percent >= 30 && $percent < 40)
{
$pollbg = '#66CCFF';
}
elseif ($percent >= 40 && $percent < 50)
{
$pollbg = '#FFFF99';
}
elseif ($percent >= 50 && $percent < 60)
{
$pollbg = '#33CCCC';
}
elseif ($percent >= 60 && $percent < 70)
{
$pollbg = '#990033';
}
elseif ($percent >= 70 && $percent < 80)
{
$pollbg = '#FF9900';
}
elseif ($percent >= 80 && $percent < 90)
{
$pollbg = '#669999';
}
elseif ($percent >= 90)
{
$pollbg = '#9933FF';
}
Save the file.
Now Go to: ACP > Templates > Your theme's templates > Showthread templates > showthread_poll_resultbit > and find;
<td class="{$optionbg}"><img src="{$theme['imgdir']}/pollbar-s.gif" alt="" /><img src="{$theme['imgdir']}/pollbar.gif" width="{$imagewidth}" height="10" alt="{$percent}%" title="{$percent}%" /><img src="{$theme['imgdir']}/pollbar-e.gif" alt="" /></td>
and Change it into;<td class="{$optionbg}">
<div>
<div style="background-color: #fff; border: 1px solid black; width:50%; margin-top: 1px; font-size: 7px;">
<div style="background-color: {$pollbg}; color: #000000; font-weight:bold; max-width:100%; width:{$percent}%; height:10px;">
{$percent}%
</div>
</div>
</div>
</td>
Now it'll look like this;
You may change these colors to suite your taste.
Now if you want to add these colors on Poll results page, then here is how;
Similarly open ./poll.php and find;
eval("\$polloptions .= \"".$templates->get("polls_showresults_resultbit")."\";");
Now add the following code just Above it;
// Poll Votes Colors
if ($percent == 10 || $percent < 10 && $percent > 0)
{
$pollbg = '#FF0000';
}
elseif ($percent >= 11 && $percent < 20)
{
$pollbg = '#33CC33';
}
elseif ($percent >= 20 && $percent < 30)
{
$pollbg = '#FF33CC';
}
elseif ($percent >= 30 && $percent < 40)
{
$pollbg = '#66CCFF';
}
elseif ($percent >= 40 && $percent < 50)
{
$pollbg = '#FFFF99';
}
elseif ($percent >= 50 && $percent < 60)
{
$pollbg = '#33CCCC';
}
elseif ($percent >= 60 && $percent < 70)
{
$pollbg = '#990033';
}
elseif ($percent >= 70 && $percent < 80)
{
$pollbg = '#FF9900';
}
elseif ($percent >= 80 && $percent < 90)
{
$pollbg = '#669999';
}
elseif ($percent >= 90)
{
$pollbg = '#9933FF';
}
Now open ACP > templates > Your theme's templates > Poll templates > "polls_showresults_resultbit" template and find;
<td class="{$optionbg}" width="{$imagerowwidth}"><img src="{$theme['imgdir']}/pollbar-s.gif" alt="" /><img src="{$theme['imgdir']}/pollbar.gif" width="{$imagewidth}" height="10" alt="{$percent}%" title="{$percent}%" /><img src="{$theme['imgdir']}/pollbar-e.gif" alt="" /><br />{$userlist}</td>
and Change it into;<td class="{$optionbg}">
<div>
<div style="background-color: #fff; border: 1px solid black; width:50%; margin-top: 1px; font-size: 7px;">
<div style="background-color: {$pollbg}; color: #000000; font-weight:bold; max-width:100%; width:{$percent}%; height:10px;">
{$percent}%
</div>
</div>
</div>{$userlist}</td>