Page 1 of 3
Web Poll Content Type
Posted: Thu 27. Oct 2005, 20:24
by JensZ
Thought I'd share my latest enhancement, a web poll for phpwcms.
See demo and download from:
http://www.ikfrej.se/index.php?downloads
Cheers!
Posted: Fri 28. Oct 2005, 08:52
by rushclub
thanks for that cp. one small question.
where can we see the results of the poll? in the backend?
cheers
rush
Posted: Fri 28. Oct 2005, 09:25
by Kosse
Hi JensZ,
great addition! Little mod, big effects, thanks.
Your one of my favourite MOD-man
Cheers
Posted: Fri 28. Oct 2005, 09:51
by JensZ
The results are shown once the user hits send. However, minutes after I released the code I actually added code so that the results can be seen in the backend. Now I'm too lazy to wrap up another package, it'll come in the next version along with code that allows the poll and results to be rendered using templates. Replace inc_tmpl\cnt89.list.inc.php with this to get it to appear in the backend:
Code: Select all
<?php
/*************************************************************************************
Copyright notice
(c) 2002-2005 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
This script is part of PHPWCMS. The PHPWCMS web content management system is
free software; you can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
A copy is found in the textfile GPL.txt and important notices to the license
from the author is found in LICENSE.txt distributed with these scripts.
This script is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
This copyright notice MUST APPEAR in all copies of the script!
*************************************************************************************/
// Content 89: Poll jens
$cinfo["result"] = $row["acontent_title"] ? cut_string($row["acontent_title"],"…", 55) : "";
$cinfo["result"] .= ($cinfo["result"] && $row["acontent_subtitle"]) ? " / " : "";
$cinfo["result"] .= $row["acontent_subtitle"] ? cut_string($row["acontent_subtitle"],"…", 55) : "";
$poll_text = unserialize($row["acontent_text"]);
$poll_form = unserialize($row["acontent_form"]);
$poll_image = unserialize($row["acontent_image"]);
$total_votes = 0;
foreach($poll_form["count"] as $key => $value)
{
$total_votes += $value;
}
$html .= "<table>";
$html .= "<tr>\n<td><table>";
if($total_votes > 0)
{
$cnt = max(count($poll_form["choice"]), count($poll_image["images"]));
for($key = 0; $key < $cnt; $key++)
{
$html .= '<tr><td class="v10">';
if(isset($poll_form["choice"][$key]) && !empty($poll_form["choice"][$key]))
{
$html .= $poll_form["choice"][$key];
}
//if(is_array($poll_image["images"][$key]) && count($poll_image["images"][$key]))
//{
// $html .= "<br/>";
// $html .= showPollImage($poll_image["images"][$key]);
//}
$html .= '</td><td class="v10"><span style="float: left; height: 13px; background-color: #0FA5FB; border-top: 1px solid #78CBFB; border-left: 1px solid #78CBFB; border-right: 1px solid #0AA3BE; border-bottom: 1px solid #0AA3BE; margin: .2em 0 .5em 0; width:'.round(($poll_form["count"][$key]/$total_votes*100),0).'px;"><!-- --></span> <span style="">'.round(($poll_form["count"][$key]/$total_votes*100),0).'%</span></td></tr>'."\n";
}
}
$html .= "<tr><td class=\"v10\"><span style=\"font-weight:bold;\">total votes:</span> ".$total_votes."</td></tr>";
$html .= "</table></td>\n</tr>";
$html .= "</table>";
if($cinfo["result"])
{
echo "<tr><td> </td><td class=\"v10\">";
echo "<a href=\"phpwcms.php?do=articles&p=2&s=1&aktion=2&id=".$article["article_id"]."&acid=".$row["acontent_id"]."\">";
echo $cinfo["result"]."</a>".$html."</td><td> </td></tr>";
}
?>
Posted: Fri 28. Oct 2005, 10:28
by Kosse
Hi,
made a test here:
http://www.piezoworks.be/mulieris/index.php?fr_mulieris
Works like a charm!!!
Some questions though... You might think "they're never happy, I break my b* to do a nice CP and they complain!" No, no, I was just wondering about these things:
Q: what is the time limit to re-enter the vote? (cookie based/session?) I suppose I can change the value?
Q: every time I edit the poll, it resets the results to 0... no tbig deal but can be annoying for future aplpications.
Q: I don't get th eimage thing, it only shows under the first choice...
Anyway, very nice job!
Thanks again!
Cheers
Posted: Fri 28. Oct 2005, 10:37
by JensZ
Nope, it is based on IP. One visitor, one vote. However, it can be reset by updating the content part in the backend, but that will reset all the votes. Maybe I'll put some reset logic in the next version...
Posted: Fri 28. Oct 2005, 11:09
by Kosse
Kosse wrote:
Q: I don't get the image thing, it only shows under the first choice...
Stupid me... if I add 4 choices, then I have to add 4 images, ok got it...
Note: funny, 12 pple voted so far
Cheers
Posted: Sun 30. Oct 2005, 14:08
by frold
hey,
what about placing the total numbers of votes....?
OFftopic - how did you made this:
Läst 411 gånger (idag: 7)
Updated 2 sec after I posted..
Display number of users currently online, number of visitors, number of times a page/article has been viewed, and more. Requires VTS
Posted: Mon 31. Oct 2005, 09:28
by JensZ
Frold,
To show the total number of votes replace
Code: Select all
$html .= "</table></td>\n</tr>";
$html .= "</table>";
with
Code: Select all
$html .= "</table></td>\n</tr>";
$html .= "<tr><td><span style=\"font-weight:bold;\">total votes:</span> ".$total_votes."</td></tr>";
$html .= "</table>";
To get the number of times an article has been read, install the vts_users_online.zip package and put something like this in your article template:
Code: Select all
<div>
[TITLE]<h1 style="margin:0 0 5px 0;">{TITLE}</h1>[/TITLE]
[SUB]<h3 style="margin:0 0 5px 0;">{SUB}</h3>[/SUB]
<p style="margin:5px 0 5px 0;">
<span>{DATE:Y-m-d:EN}</span>
<span>
Read {VTS_DOCUMENT:total} times (today: {VTS_DOCUMENT:today}).</span><br />
{SUMMARY}
</p>
<br/>
</div>
cheers
/Jens
Posted: Mon 31. Oct 2005, 09:40
by Kosse
JensZ wrote:To show the total number of votes replace
Done, works like a charm (as always) thx JensZ
Cheers
Re: Web Poll Content Type
Posted: Mon 31. Oct 2005, 10:56
by Dave_LOgic
Another awesome content part..!!.I use both of your {SHOW_CONTENT} and {NEWS_FLASH} hacks....I haven't installed this one yet as it looks that this one involves modifying the same core files...Is this the case..??
Posted: Mon 31. Oct 2005, 13:42
by JensZ
Yes, changes are made to the same files, but the changes are minor. A function in front.func.inc.php and a line or two in the other files. Just look for "jens" to find the lines that changed and merge them in.
Posted: Mon 31. Oct 2005, 17:55
by Dave_LOgic
JensZ wrote:Yes, changes are made to the same files, but the changes are minor. A function in front.func.inc.php and a line or two in the other files. Just look for "jens" to find the lines that changed and merge them in.
Many thanks....I have done as you said and all is working OK now...
Posted: Mon 5. Dec 2005, 14:15
by Paal
JensZ wrote:Yes, changes are made to the same files, but the changes are minor. A function in front.func.inc.php and a line or two in the other files. Just look for "jens" to find the lines that changed and merge them in.
Fine this MOD, but I have one question. How to hide the poll results to end off poll period (secret poll)?
eg.: after user vote, say "thx, the vote. Results later..."
Thx, Paul
Posted: Tue 6. Dec 2005, 07:33
by trip
Hi Jens
could you post this mod with all the install features on --...-- ?
TriP