Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Drupal's poll results are output as a unique string divide in more text lines, one for hit with three information fields: choice, votes number, percentage.
Would it be better to tag the results output in a definition list?
I managed to modify the output string just using Php in poll-results.tpl.php, which can be overridden: I changed print $results;
with two blocks:
$risultati=str_replace("(", " [", $results);
$risultanze=str_replace(")", "] ", $risultati);
$voti = str_replace("\r\n\r\n", "", $risultanze);
$esiti=explode(" ", $voti, -1);
$sections=array_chunk($esiti, 3);
print "<dl>\n";
foreach ($sections as $section) {
print "<dt>$section[0]</dt>\n";
print "<dd>" . $section[1]. "</dd>\n";
print "<dd>" . $section[2]. "</dd>\n";
}
print "</dl>\n";
It seems to work.
I hpe it may be useful.
Comment | File | Size | Author |
---|---|---|---|
#13 | 1315616-13.patch | 801 bytes | amateescu |
#11 | 1315616-11.patch | 811 bytes | amateescu |
#8 | testing-dl-4-polls.png | 138.74 KB | mgifford |
#7 | 1315616-7.patch | 2.22 KB | amateescu |
#5 | 1315616.patch | 1.52 KB | amateescu |
Comments
Comment #1
mgiffordNot sure about the approach (and it would have to be with English variables), but do like the result.
What are the possible performance issues? There's no need to use extra HTML elements I assume.
Comment #2
webchickWe can't make changes to core modules' output in 7.x, but we can look at it for 8.x.
Comment #3
francesco_sardegna CreditAttribution: francesco_sardegna commentedFor the next suggestion (I hope there will be) I shall use English variables, even if for example.
Perhaps this code may help understand the meaning of the poll results giving each data the right collocation (dt is the answer and dd are the number of votes and the percentage) and the right rythm.
I would not know how to tag it without using extra Html elements.
Comment #4
mgiffordThat's great. It's also easier to refer to a patch. Not sure if you've looked into this but http://drupal.org/node/707484
Comment #5
amateescu CreditAttribution: amateescu commentedHow about something like the attached patch? It gives us this nice structure:
I didn't include any screenshots because there is absolutely no change :)
Comment #7
amateescu CreditAttribution: amateescu commentedHmpf.
Comment #8
mgiffordA simple but effective patch. HTML output is:
Patch applies nicely & looks just fine.
Comment #9
Dries CreditAttribution: Dries commentedCommitted to 8.x. Thanks.
Comment #10
sunWe use "\n" everywhere else throughout Drupal core for consistency.
Comment #11
amateescu CreditAttribution: amateescu commentedSorry for that :/
Comment #13
amateescu CreditAttribution: amateescu commentedOr even with less chars :) I'll set to needs review when HEAD gets unbroken.
Comment #14
sunComment #15
catchCommitted/pushed the follow-up, thanks!