XF 1.5 Hide number of votes from poll results

Ingenious

Well-known member
I would like to remove the number of votes in poll results, just in certain cases (eg. on a per poll or per node basis). So for example, this default view:

Screen Shot 2018-11-07 at 13.38.32.webp

Would just show the bars plus 45.6%, 21.4% and 33.0%

(Even better, number of votes show only to admin).

Is this going to be possible via a template modification, for example wrapping the number of votes in a conditional that blanks it if node=x and user!=admin?

If not, where do I go to solicit for a custom add-on? (I have not been that active on XF for a little while). Couldn't find anything remotely close in Resources.

Thanks :)
 
I've done this after some tinkering with the template poll_block_result (tabbed in thread_poll_results). This will remove the number of voters on a per node basis but only for non-admin.

Find:

Code:
{xen:phrase x_votes, 'count={xen:number $response.response_vote_count}'}

And surround it with the following conditional:

Code:
<xen:if is="{$forum.node_id} != 999 OR {$visitor.is_admin}">{xen:phrase x_votes, 'count={xen:number $response.response_vote_count}'}</xen:if>

This only shows the number of voters if the poll is displayed either outside of the chosen node (change 999 to suit you) or the user is admin in which case they will always show. It made no difference using $forum.node_id or $thread.node_id to find the node ID.

Alternatively the {$thread.thread_id} == x conditional could apply to specific threads though you'd need to create the poll then edit the template with that thread number.

This is no substitute for a nice plugin option but will suffice if the number of polls you want to screen the voter numbers from are either small or can be organised into a specific forum.
 
Back
Top Bottom