Dabei erhält die höchste Anzahl Stimmen grüne, die zweithöchste Anzahl Stimmen orange und alle anderen Optionen rote Balken.
Code: Alles auswählen
#
#-----[ OPEN ]-----
#
viewtopic.php
#
#-----[ FIND ]-----
#
while ($row = $db->sql_fetchrow($result))
{
$poll_info[] = $row;
}
$db->sql_freeresult($result);
#
#-----[ AFTER, ADD ]-----
#
// Poll max information system - OXPUS
$sql = 'SELECT poll_option_total FROM ' . POLL_OPTIONS_TABLE . "
WHERE topic_id = $topic_id
GROUP BY poll_option_total
ORDER BY poll_option_total DESC
LIMIT 2";
$result = $db->sql_query($sql);
$poll_max_color = array();
while ($row = $db->sql_fetchrow($result))
{
$poll_max_color[] = $row['poll_option_total'];
}
$db->sql_freeresult($result);
// Poll max information system - OXPUS
#
#-----[ FIND ]-----
#
foreach ($poll_info as $poll_option)
{
$option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
$option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));
#
#-----[ AFTER, ADD ]-----
#
// Poll max information system - OXPUS
if ($poll_max_color[0] == $poll_option['poll_option_total'])
{
$poll_option_color = 'green';
}
else if ($poll_max_color[1] == $poll_option['poll_option_total'])
{
$poll_option_color = 'orange';
}
else
{
$poll_option_color = 'red';
}
// Poll max information system - OXPUS
#
#-----[ FIND ]-----
#
'POLL_OPTION_PERCENT' => $option_pct_txt,
#
#-----[ AFTER, ADD ]-----
#
'POLL_OPTION_COLOR' => $poll_option_color,
#
#-----[ OPEN ]-----
#
styles/prosilver/template/viewtopic_body.html
#
#-----[ FIND ]-----
#
<!-- IF S_DISPLAY_RESULTS --><dd class="resultbar"><div class="<!-- IF poll_option.POLL_OPTION_PCT < 20 -->pollbar1<!-- ELSEIF poll_option.POLL_OPTION_PCT < 40 -->pollbar2<!-- ELSEIF poll_option.POLL_OPTION_PCT < 60 -->pollbar3<!-- ELSEIF poll_option.POLL_OPTION_PCT < 80 -->pollbar4<!-- ELSE -->pollbar5<!-- ENDIF -->" style="width:{poll_option.POLL_OPTION_PERCENT};">{poll_option.POLL_OPTION_RESULT}</div></dd>
#
#-----[ IN-LINE FIND ]-----
#
pollbar5<!-- ENDIF -->" style="width:{poll_option.POLL_OPTION_PERCENT};
#
#-----[ IN-LINE AFTER, ADD ]-----
#
background-color: {poll_option.POLL_OPTION_COLOR}; border: none;
Dieses Snippet ist auf diesem Forum installiert und als Beispiel dient diese Umfrage: http://phpbb3.oxpus.net/viewtopic.php?f=5&t=47