Welcome to Geeklog, Anonymous Thursday, January 09 2025 @ 05:37 am EST
Geeklog Forums
Poll Admin Weirdness
Status: offline
alinford
Forum User
Regular Poster
Registered: 01/06/03
Posts: 96
I have a poll with 11 possible answers (all slots are filled).
The poll shows up correctly, but when I go into the admin area to edit it, the 10th option shows up in both the 10th spot and the 11th spot. If I edit the 11th, it shows up on the home page with my edits, but still shows up in the admin area the same as the 10th.
Any idea how to fix this?
9
9
Quote
Status: offline
tomw
Forum User
Full Member
Registered: 08/12/02
Posts: 300
That's a bug in the poll editor -- even though it shows 11 slots you can only use 10. I ran across this some time back and reported it. It probably got lost in the confusion. The problem is in poll.php in the admin directory.
In the function editpoll on about line 267 of the file you will find:
for ($i = 0; $i < $_CONF['maxanswers']; $i++) {
$A = DB_fetchArray($answers);
$poll_templates->set_var('answer_text', htmlentities ($A['answer']));
$poll_templates->set_var('answer_votes', $A['votes']);
$poll_templates->parse('answer_option','answer',true);
}
The problem is each time you parse the template it generates another blank for use again. The blank has the same values as the preceding entry. So you need to change it so that on the last time through the loop it does not parse the template. That would be when $i=maxanswers - 1. So replace the last line in the loop above with:
if ($i != ($_CONF['maxanswers'] - 1)) {
$poll_templates->parse('answer_option','answer',true);
}
It's fixed.
TomW
9
10
Quote
Status: offline
alinford
Forum User
Regular Poster
Registered: 01/06/03
Posts: 96
Thanks for the help, I must have misunderstood where this was supposed to go.
I replaced:
for ($i = 0; $i < $_CONF['maxanswers']; $i++) {
$A = DB_fetchArray($answers);
$poll_templates->set_var('answer_text', htmlentities ($A['answer']));
$poll_templates->set_var('answer_votes', $A['votes']);
$poll_templates->parse('answer_option','answer',true);
}
With this:
for ($i = 0; $i < $_CONF['maxanswers']; $i++) {
$A = DB_fetchArray($answers);
$poll_templates->set_var('answer_text', htmlentities ($A['answer']));
$poll_templates->set_var('answer_votes', $A['votes']);
if ($i != ($_CONF['maxanswers'] - 1))
$poll_templates->parse('answer_option','answer',true);
}
That seems to work.
I tried this:
for ($i = 0; $i < $_CONF['maxanswers']; $i++) {
$A = DB_fetchArray($answers);
$poll_templates->set_var('answer_text', htmlentities ($A['answer']));
$poll_templates->set_var('answer_votes', $A['votes']);
if ($i != ($_CONF['maxanswers'] - 1)) {
$poll_templates->parse('answer_option','answer',true);
}
But then the brackets were uneven.
I also tried this:
for ($i = 0; $i < $_CONF['maxanswers']; $i++) {
$A = DB_fetchArray($answers);
$poll_templates->set_var('answer_text', htmlentities ($A['answer']));
$poll_templates->set_var('answer_votes', $A['votes']);
if ($i != ($_CONF['maxanswers'] - 1)) {
$poll_templates->parse('answer_option','answer',true);
}
}
But that did not seem to work either.
Am I missing somthing?
11
8
Quote
Anonymous
Anonymous
Sorry, I did not make it clear, replace the entire section with:
for ($i = 0; $i < $_CONF['maxanswers']; $i++) {
$A = DB_fetchArray($answers);
$poll_templates->set_var('answer_text', htmlentities ($A['answer']));
$poll_templates->set_var('answer_votes', $A['votes']);
if ($i != ($_CONF['maxanswers'] - 1)) {
$poll_templates->parse('answer_option','answer',true);
}
}
This works, its lifted out of my file.
TomW
9
12
Quote
All times are EST. The time is now 05:37 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content