Jump to content

Pollino (Simple Polls for ProcessWire)


Soma

Recommended Posts

Just checked in a first beta version of a new module I'm working on. Feel free to test out and see what's up with it.

Pollino (beta)

A simple poll module for ProcessWire

This module makes it simple to setup polls for your website. It is based on a simple page setup to create the polls. So each poll is a page, and its children are the answers. Pollino will create the templates and a PollinoPolls page in the root to start with. You can add fields to the templates as you wish and later use hooks to modify the output of the poll. This can be useful, for example, to use images as options or just some custom markup etc.

It provides some API to render the poll form and the result. These methods are hookable and it's easy to customize the output if needed. It can be rendered on any page and even multiple on the same page.

Pollino takes care of saving the votes and preventing multiple votes. It comes with some configuration settings to choose what method to use to prevent from multiple votings:

  • using cookie and an expire time
  • or by IP and optionally also the UserAgent with and expire time
  • or by logged in User

Pollino isn't 100% plug'n'play but it provides a solid foundation and comes with some premade theme and output for you to start. It takes care of the boring stuff and lets you concentrate on the front-end stuff and styling. That's what matters after all.

It does support multilanguage, as all strings are translatable in the module. Also since it's using simple pages and templates you're free to add or change fields to make its output multilanguage without much hassle.

-----

Read more and download

https://github.com/somatonic/Pollino

Online Demo

I setup a little demo here to see using https://lightning.pw

http://titanium-x77.lightningpw.com/

Have fun.

post-100-0-55378600-1425661856_thumb.png post-100-0-02109700-1425661865_thumb.png

  • Like 31
Link to comment
Share on other sites

How cool.

I'm in discussions with a client to move his pretty large site over to PW. One of the features that I could see being a problem was a custom developed Poll snippet the client loves on his current site.

I was literally worrying about this all week and how client would take news that his 'upgraded' site didn't have one of his most often used features

Thanks so much!

  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...
  • 4 months later...

Hi Soma

Just tried the Pollino module and it's fab.

I'm not very familiar with the delayed output method you recommend here

// may needs modification as this examples uses delayed output
// but you get the idea
$content .= "<div class='pollino_poll'>";
$content .= "<div class='inner'>";
$content .= "<h3>$page->title</h3>";
$content .= $modules->Pollino->renderPoll($page);
$content .= "</div>";
$content .= "</div>";

To get it to output anything, I needed to tweak as follows. That's the recommened way, right?

<?php
$page->children;
{
$content .= "<div class='pollino_poll'>";
$content .= "<div class='inner'>";
$content .= "<h3>$page->title</h3>";
$content .= $modules->Pollino->renderPoll($page);
$content .= "</div>";
$content .= "</div>";
}
echo $content;
?>
Link to comment
Share on other sites

You don't need the brackets or the last ?>. What's $page->children doing there?

Just use ...

echo $content;

... and you're fine.

Complete solution:

<?php

$content = ""; // Set variable
$content .= "<div class='pollino_poll'>"; // .= means append this string/text too
$content .= "<div class='inner'>";
$content .= "<h3>$page->title</h3>";
$content .= $modules->Pollino->renderPoll($page);
$content .= "</div>";
$content .= "</div>";

echo $content; // Output variable
  • Like 1
Link to comment
Share on other sites

  • 2 years later...

Hi to all! 

First of all -> Thank you for this great module. 

I had a problem on rendering the results. Progressbars had always a width of 100%, because they do not take "," in Chrome. I managed to fix it by declaring round($var, 0) on line 231 of the module! 

 

 foreach($answers as $answer) {
                $answer->vote_percent = isset($data[$answer->id]) ? round((100/$total) * $data[$answer->id]['vote_count'], 0) : 0; //change
                $answer->vote_count = isset($data[$answer->id]) ? $data[$answer->id]['vote_count'] : 0;
                $data[$answer->id]['vote_text'] = $answer->title;
                $data[$answer->id]['vote_count'] = $answer->vote_count;
                $data[$answer->id]['vote_percent'] = round($answer->vote_percent);
            }

Just in case sombody has this issue too. Now it works perfektly! 

 

Link to comment
Share on other sites

  • 4 months later...

Hi @Soma! First of all, thanks for another really useful module. Since I'm planning to add polls to my blog site profiles, I've dabbled with it abit. To make things work nicely with the existing templates, I had to tweak a bit of the generated HTML and, in the course of that, changed your module a bit:

  • It now uses templates for every bit of HTML produced
  • Added config settings for all these HTML template snippets
  • There's a template for the main wrap, so wrapping the renderPoll() return manually is no longer necessary
  • Added a config option and poll template field for a poll closing date (+time)
  • pollino-ajax-script.js now wraps a div around the result before inserting it. That prevents a jQuery error if the result contains more than one HTML element.
  • I'm storing any array $config data passed to renderPoll() in the user session and retrieve it in the AJAX action
  • Added collapsed fieldsets for different template areas (generic, form, result) in the module config
  • Last but not least, added "PHP" hints to the code blocks in README.md

I have made a fork and added a branch with all these changes here. Perhaps you could give it a look (test drive?) and tell me if I should prepare a pull.

  • Like 6
Link to comment
Share on other sites

Update:

I have been playing around some more. There's now another branche dev-bitpoet-cke that includes a Textformatter which replaces ##POLL:name-of-poll-page## with the poll output and a CKEditor plugin for easy insertion.

 

poll-cke-1.png.236b5462cc9825c9bb3975bdca4e2894.png

 

poll-cke-2.png.15839da1876025349cd5d2882d7d73fc.png

 

poll-cke-3.thumb.jpg.dfa59a27e62b7c5fdc131a6604b5410c.jpg

  • Like 5
Link to comment
Share on other sites

12 hours ago, BitPoet said:

I have been playing around some more.

@teppo seemed to be working on it recently too, but I'm not aware of him making his changes public. See:

https://weekly.pw/issue/170/

"This week we don't have a poll section. This is mainly due to some additional tweaks to the Pollino module that we're making in preparation for next week's poll..."

Link to comment
Share on other sites

2 hours ago, szabesz said:

@teppo seemed to be working on it recently too, but I'm not aware of him making his changes public. See:

Unless my memory fails me, all I did was add support for multiple answers and user-submitted suggestions. Might've made some general purpose (JavaScript/CSS?) tweaks too, not entirely sure anymore.

Once the current version stabilises, i.e. I know whether the updates from @BitPoet get merged in, I could set up a new PR for these :)

  • Like 3
Link to comment
Share on other sites

7 hours ago, teppo said:

Once the current version stabilises, i.e. I know whether the updates from @BitPoet get merged in, I could set up a new PR for these :)

That would be brilliant. Though @Soma might have to rename his module from Pollino to Pollissimo (it feels like it's about to outgrow the diminutive...) ;)

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Hi Guys,

I'm hoping to get some suggestions. I'm using Pollino on a site and it's working great, thanks to Soma and BitPoet (I'm using his version for this project). The boss wants to prevent voters from seeing results after they vote. The site is for a home owners association and only logged in members can vote but the president of the association wants to be able to use the poll results to present to municipal council as official feedback on local issues so he wants to be able to present the results of each poll himself, after the voting period expires.

I'm hoping a simple conditional can be used to only present results to the admin role and just a thank you for voting to members but I can't seem to make it work. Can someone who has dived deeper into the code than I help me with a place to start?

Link to comment
Share on other sites

59 minutes ago, dragan said:

@digitex I haven't used this module yet, but I guess what you're looking for is this hookable method: https://github.com/somatonic/Pollino#hooks-to-modify-output

Thanks @dragan. The hooks in that link are the correct way to do what I want and I will read up on it. It's better than changing the code in the module I think.

 

Link to comment
Share on other sites

  • 1 year later...

First of all thanks soma for the module. I use Processwire for an intranet with registered Users. For this I try to setup Pollino with logged in Users to prevent from multiple votings.

All works fine. But the Method "Prevent Multiple Votings" by User doesn't work. After voting the user can vote again and again. Can anyone give me a hint what is to do?

Link to comment
Share on other sites

Hi @astock, welcome to the PW forums.

I haven't used this module myself, but looking at the code I think you need to configure it not to check by cookies | IP | UserAgent, but by user!

Then there is a public function that you may query in your template file(s) before you display a poll form: https://github.com/somatonic/Pollino/blob/master/Pollino.module.php#L460

Can you check that you have configured all right for using users? Can you test if the above mentioned method is of any help in your case, or at least shed some light? As far as I understand this, after the first vote of a loggedin user, this method should return that he already has voted.

If this doesn't help to bring you further, please come back again here. :-)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...