poll with picture

Post

Posted
Rating:
#5936 (In Topic #1230)
I'm a big fan of the polls feature of Composr and was wondering if there was a way to include a picture beside the poll?  Most people are visual and I think adding a picture associated with the Poll helps to emphasize and promote the poll, and adds a bit of polish, professionalism as well :)

Here's an example of what I'm talking about:
wind-chimes-poll.png
Is this something that can be done already?  Or should this be a new feature add?

Best,
Christopher
 

Post

Posted
Rating:
#5946
It can be done.

Go to Content Management > Polls > Choose custom 'Poll' fields.

Add a new 'Picture' field.

Add/edit polls(s) with that field filled in.

Then you need to make a couple of template edits. The below shows the changes needed. I just tested right on top of the default templates, but you'd do it using the template editor to create overrides.

Code (Diff)

diff --git a/themes/default/templates/POLL_BOX.tpl b/themes/default/templates/POLL_BOX.tpl
index f9c7b9b18..76d5a5dac 100644
--- a/themes/default/templates/POLL_BOX.tpl
+++ b/themes/default/templates/POLL_BOX.tpl
@@ -18,8 +18,15 @@
                {$INSERT_SPAMMER_BLACKHOLE}
        {+END}
 
-               <div>
-                       {CONTENT}
+               <div style="display: flex">
+                       <div style="margin-right: 1em">
+                               {$SET,bound_catalogue_entry,{$CATALOGUE_ENTRY_FOR,poll,{PID}}}
+                               {+START,IF_NON_EMPTY,{$GET,bound_catalogue_entry}}{$CATALOGUE_ENTRY_FIELD_VALUE,{$GET,bound_catalogue_entry},0}{+END}
+                       </div>
+
+                       <div>
+                               {CONTENT}
+                       </div>
                </div>
 
                {+START,IF_NON_EMPTY,{RESULT_URL}}
diff --git a/themes/default/templates/POLL_SCREEN.tpl b/themes/default/templates/POLL_SCREEN.tpl
index e508657f9..2427721f8 100755
--- a/themes/default/templates/POLL_SCREEN.tpl
+++ b/themes/default/templates/POLL_SCREEN.tpl
@@ -15,9 +15,6 @@
        {POLL_DETAILS}
 </div>
 
-{$SET,bound_catalogue_entry,{$CATALOGUE_ENTRY_FOR,poll,{ID}}}
-{+START,IF_NON_EMPTY,{$GET,bound_catalogue_entry}}{$CATALOGUE_ENTRY_ALL_FIELD_VALUES,{$GET,bound_catalogue_entry}}{+END}
-
 <div class="float_surrounder lined_up_boxes">
        {+START,IF_NON_EMPTY,{TRACKBACK_DETAILS}}
                <div class="trackbacks right">
 

Post

Posted
Rating:
#5954

Chris Graham said

It can be done.

Go to Content Management > Polls > Choose custom 'Poll' fields.

Add a new 'Picture' field.

Add/edit polls(s) with that field filled in.

Then you need to make a couple of template edits. The below shows the changes needed. I just tested right on top of the default templates, but you'd do it using the template editor to create overrides.



Awesome.  This worked great.  Thanks!

The only thing I noticed when testing was that when I went to Preview the 'Add Poll' entry the picture did not display in the preview.  Otherwise, everything else worked just as expected.   :thumbs:

Post

Posted
Rating:
#5956
Cool   :cool: .

I didn't consider previews, but that's a tricky thing. I've added a tracker issue for it.
0004224: Support custom fields on previews - Composr CMS feature tracker

Post

Posted
Rating:
#5957

Chris Graham said

Cool   :cool: .

I didn't consider previews, but that's a tricky thing. I've added a tracker issue for it.
0004224: Support custom fields on previews - Composr CMS feature tracker

No worries.  Just wanted to point out that I didn't see the image on the preview, so that you were aware.  As is, it still works very well (ignoring the lack of preview, of course, which isn't a show-stopper).  Thanks!
0 guests and 0 members have recently viewed this.