Simple Forum 1.01 Released!

By Toledoh - April 9, 2016 - edited: April 10, 2016

Hey all.

Not sure if anyone's interested or not, but I’ve played with the Forum Polls - I wanted to chart the data in an animated bar chart. You can see it here: http://server.toledoh.com/~cmsbtest/forum/forum-posts.php?Another-Test-Poll-3

I added CSS.

.chart {

  display: table;

  table-layout: fixed;

  width: 60%;

  max-width: 700px;

  height: 200px;

  margin: 0 auto;

  background-image: linear-gradient(to top, rgba(0, 0, 0, 0.1) 2%, rgba(0, 0, 0, 0) 2%);

  background-size: 100% 50px;

  background-position: left top;

}

.chart li {

  position: relative;

  display: table-cell;

  vertical-align: bottom;

  height: 200px;

}

.chart span {

  margin: 0 1em;

  display: block;

  background: rgba(209, 236, 250, 0.75);

  animation: draw 1s ease-in-out;

}

.chart span:before {

  position: absolute;

  left: 0;

  right: 0;

  top: 100%;

  padding: 5px 1em 0;

  display: block;

  text-align: center;

  content: attr(title);

  word-wrap: break-word;

}

@keyframes draw {

  0% {

    height: 0;

  }

}

I changed this in simpleForum-html.php

  // get answers and results

  $answers    = '';

  $totalVotes = (int) $poll['pollVotes1'] + $poll['pollVotes2'] + $poll['pollVotes3'] + $poll['pollVotes4'] + $poll['pollVotes5']

              + $poll['pollVotes6'] + $poll['pollVotes7'] + $poll['pollVotes8'] + $poll['pollVotes9'] + $poll['pollVotes10'];

  foreach (range(1,10) as $num) {

    $answer   = $poll["pollAnswer$num"];

    if ($answer == '') { continue; }

    $votes    = $poll["pollVotes$num"];

    $percent  = $totalVotes ? (($votes / $totalVotes) * 100) : 0;

    $percent  = sprintf("%.0f", $percent);

    $voteLink = $GLOBALS['SFORUM_POSTS_URL'] . "?postNum=$postNum&vote=$num";

    if ($userVoted) { $answers .= "<li><span style='height:$percent%' title='$answer'></span></li>\n"; }

    else            { $answers .= "<li><a href='$voteLink' class='btn btn-sm btn-default'>" . t('Vote') . " - $answer</a></li>\n"; }

  }

  if ($userVoted) { $answers .= "</ul><p>" . t('Votes') . ": $totalVotes</p>\n"; }

  // create output list

  $html  = "<div class='sforum-poll'>";

  $html .= "  <b>" . t('Poll') . ":</b><br/>\n";

  $html .= "<ul class='chart'>\n";

  $html .= $answers;

  $html .= "</div>";

  //

  return $html;

}

Cheers,
Tim (toledoh.com.au)

By gregThomas - April 11, 2016

Hey Tim, that looks great! I like the way it animates after you've voted.

Greg Thomas

PHP Programmer - interactivetools.com

By Djulia - April 15, 2016

Hi, Greg,

Is there a version for CMSB 2.65?
We have a very large site which cannot be updated now.

Thanks!
Djulia

By gregThomas - April 18, 2016

Hey Djulia, 

We've not tested the forum with version 2.65, but I can't think of any reason why it wouldn't work. We have a 90 day money back guarantee, so if the forum doesn't work correctly, you'd be able to return it without any issue. 

To get the plugin to install, you'd have to make the following change to the file simpleForum/simpleForum.php

<?php
/*
Plugin Name: Simple Forum
Description: Simple website discussion forum
Version: 1.01
Requires at least: 2.65
*/

Let me know if you have any questions. 

Cheers,

Greg

Greg Thomas

PHP Programmer - interactivetools.com