poll with picture
Posted
#6628
(In Topic #1716)

Standard member

Here's an example of what I'm talking about:

Is this something that can be done already? Or should this be a new feature add?
Best,
Christopher
Posted

Site director

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">
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">
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Posted

Standard member

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.
From “Post #6,639”, 2nd May 2020, 3:18 am
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.

Posted

Site director


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
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Posted

Standard member

Chris Graham said
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
From “Post #6,649”, 4th May 2020, 6:18 pm
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!
1 guest and 0 members have just viewed this.