• Welcome to Simple Machines Community Forum. Please login or sign up.
January 20, 2022, 09:10:11 AM

News:

Join the Facebook Fan Page.


Who Voted What?

Started by Søren Bjerg, August 30, 2006, 09:25:16 PM

Previous topic - Next topic

Illori

find

Code (display.template.php) Select

echo '' . $option['bar'] . ' ' . $option['votes'] . ' (' . $option['percent'] . '%)<br />';

Code (replace) Select

echo '' . $option['bar_ndt'] . ' ' . $option['votes'] . ' (' . $option['percent'] . '%)<br />';

Acer1

This Mod for SMF 2.0.1 ????

H-J Kaabii

I was wondering (using relevant modifications to code to optimise for 2.0 Gold upwards) how I could incorporate the code from Display.template.php into the theme I'm using, Bright Forest. The theme's Display.template.php for some reason does not include if ($context['allow_poll_view'])
echo '
', $option['bar_ndt'], '
<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';

but I'm unsure if this is because the theme calls up the default theme's code or for some other reason.

Sapozhnik

March 19, 2012, 05:52:15 PM #463 Last Edit: March 19, 2012, 06:30:43 PM by Illori
Quote from: rbeuker on February 23, 2011, 03:15:52 PM
I have got it working on a patched RC4 version--I'm not sure if it'd also work on RC5.

USE AT YOUR OWN RISK!!

Check the contents of the modification.xml file and find the section that changes the Display.template.php file.
Below's the code I've used:

  <file name="$themedir/Display.template.php">
    <operation>
      <search position="replace"><![CDATA[ // Show each option with its corresponding percentage bar.
foreach ($context['poll']['options'] as $option)
{
echo '
<dt class="middletext', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
<dd class="middletext statsbar', $option['voted_this'] ? ' voted' : '', '">';

if ($context['allow_poll_view'])
echo '
', $option['bar_ndt'], '
<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';

echo '
</dd>';
}

]]></search>
      <add><![CDATA[ // Show each option with its corresponding percentage bar.
foreach ($context['poll']['options'] as $option)
{
if (!allowedTo('poll_view_voters') || $modSettings['whovotedwhatMode'] == 'disabled')
{
echo '
<dt class="middletext', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
<dd class="middletext statsbar', $option['voted_this'] ? ' voted' : '', '">';

if ($context['allow_poll_view'])
echo '
', $option['bar_ndt'], '
<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';

echo '
</dd>';
}
else
{
switch ($modSettings['whovotedwhatMode'])
{
case 'select':
echo '
<dt class="middletext', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
<dd class="middletext statsbar">';
if ($context['allow_poll_view'])
{
echo '' . $option['bar'] . ' ' . $option['votes'] . ' (' . $option['percent'] . '%)' . ' ' . '<select id="jumpto" name="voters' . $option['ID_OPTION'] . '" onchange="if (this.selectedIndex > 0 &amp;&amp; this.options[this.selectedIndex].value) window.location.href = smf_scripturl + this.options[this.selectedIndex].value.substr(smf_scripturl.indexOf(\'?\') == -1 || this.options[this.selectedIndex].value.substr(0, 1) != \'?\' ? 0 : 1);" style="width: 150px;">';
if (!empty($context['poll']['options'][$option['ID_OPTION']]['voters']))
              {
                echo '
                    <option selected="selected" value="#">' . $txt['poll_view_voters_expand_to_view'] . '</option>
                    <option disabled="disabled" value="">----------------------</option>';
                foreach ($context['poll']['options'][$option['ID_OPTION']]['voters'] as $voter)
                {
                  echo '
                    <option value="?action=profile;u=' . $voter['ID_MEMBER'] . '"> => ' . $voter['realName'] . '</option>';
                }
                echo '
                    <option disabled="disabled" value="">----------------------</option>
                    <option disabled="disabled" value="">' . $txt['poll_view_voters_expanded_help1'] . '</option>
                    <option disabled="disabled" value="">' . $txt['poll_view_voters_expanded_help2'] . '</option>';
              }
              else
              {
                echo '
                    <option selected="selected" value="">----------------------</option>';
              }
              echo '
                  </select>';
}
else
{
echo '';
}
echo '</dd>';
break;
case 'table':
echo '
<dt class="middletext', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
<dd class="middletext statsbar">';
if ($context['allow_poll_view'])
{
echo '' . $option['bar'] . ' ' . $option['votes'] . ' (' . $option['percent'] . '%)<br />';
if (!empty($context['poll']['options'][$option['ID_OPTION']]['voters']))
              {
                foreach ($context['poll']['options'][$option['ID_OPTION']]['voters'] as $voter)
                {
                  echo '<small><a href="?action=profile;u=' . $voter['ID_MEMBER'] . '">', $voter['realName'], '</a></small> ';
                }
              }
}
else
{
echo '';
}
echo '</dd>';
break;
}
}
}

]]></add>
    </operation>
  </file>


In the package-info.xml file you can change "RC2" to your Forum version (RC3, RC4 or RC5).

I have not changed the wvwDB.php file.

Put all 3 files into a zip file and try installing it using the package manager.

Good luck! :)

Thanks a lot.
Package for SMF 2.0.2 is attached

Important!!!
     Activate: Features and options -> "Who Voted What? mode"
      Permission: Set permission for users group

Illori

this mod does not have a license so you are not allowed to update it without permission from the author. so your attachment has been removed.


Ray Cardillo

Quote from: Acer1 on November 27, 2011, 06:34:57 AM
This Mod for SMF 2.0.1 ????

FYI, since this one didn't offer it, I created another mod that was recently approved for release that provides several levels of visibility and allows you to configure required comments, etc.

http://custom.simplemachines.org/mods/index.php?mod=3373
Author of the Voter Visibility mod customization.  Adds the ability to see (and control who sees) who voted for what.  Allows you to conduct secret ballots.  Can also be used to coordinate volunteer signups, and more.

CedarMill

April 18, 2014, 10:05:25 AM #467 Last Edit: April 18, 2014, 02:10:00 PM by Illori
Modification Who Voted What for SMF 2.0.7 (archive attached to the message) 8)
SMF 2.0.7

Illori

since the mod has no license you are not allowed to modify it and then attach the modified package anywhere, or distribute it.

lemur21

Has this ever been updated for 2.0? This was a FANTASTIC mod (and, sadly, the others don't seem to have the same functionality).

Advertisement: