Recent searches


No recent searches

Closing Votes on Community Post

Answered


Posted Oct 29, 2021

Is there a way to close the ability to vote on a community post same as you would close a post for comments?


2

4

4 comments

Hi DJ,

You can disable voting on community posts by commenting out the respective part in the HBS file article_page.hbs:

        <!-- Disable article voting
{{#with article}}
<div class="article-votes">
<span class="article-votes-question" id="article-votes-label">{{t 'was_this_article_helpful'}}</span>
<div class="article-votes-controls" role="group" aria-labelledby="article-votes-label">
{{vote 'up' role='radio' class='button article-vote article-vote-up' selected_class="button-primary"}}
{{vote 'down' role='radio' class='button article-vote article-vote-down' selected_class="button-primary"}}
</div>
<small class="article-votes-count">
{{vote 'label' class='article-vote-label'}}
</small>
</div>
{{/with}}
-->

Cheers,
Matthias

0


image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

Hi Dj Childs,

To disable the community post votes same as the comment section, follow the below steps:

1). Add the jQuery library into the document_head.hbs file.

<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>

 

Screenshot for the same:

 

2). Copy the below script code and paste it at the bottom (After the all existing script code) into your script.js file.

$(document).ready(function(){
if (HelpCenter.user.role=="manager"){
if (localStorage.getItem('isVisible') === 'true') {
$('.vote-button').addClass('hidden_vote');
}

$('.close-vote').on('click', function() {
location.reload();
$('.vote-button').toggleClass('hidden_vote');
localStorage.setItem('isVisible', $('.vote-button').hasClass('hidden_vote'));

});

if ($(".vote-up.vote-button").hasClass("hidden_vote")) {
$('.close-vote').text("Open for vote");
}else{
$('.close-vote').text("Close for vote");
}
}
if (HelpCenter.user.role=="end-user" || HelpCenter.user.role=="agent" || HelpCenter.user.role=="end_user" || HelpCenter.user.role=="anonymous"){
$(".dropdown-menu.click-to-vote").hide();
}
});

 

Screenshot for the same:

 

3). Copy the below CSS code and paste it at the bottom area into style.css file.

.vote-button {
display: block;
}

.vote-button.hidden_vote {
display: none;
}

 

Screenshot for the same:

 

4). Now, customize your default post vote HTML code on community_post_page.hbs file.

Replace your default post-vote code with the below-given code.

{{#with post}}

{{#vote 'up' role='radio' class='vote-up vote-button' selected_class='vote-voted'}}

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" focusable="false" viewBox="0 0 16 16">

<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M4 6.5l3.6 3.6c.2.2.5.2.7 0L12 6.5"/>

</svg>

{{/vote}}

<div style="position:relative;">

{{vote 'sum' class='vote-sum dropdown-toggle'}}

<div class="dropdown-menu click-to-vote" role="menu">

<a role="menuitem" href="javascript:void(0)" class="close-vote"></a>

</div>

</div>

{{#vote 'down' role='radio' class='vote-down vote-button' selected_class='vote-voted'}}

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" focusable="false" viewBox="0 0 16 16">

<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M4 6.5l3.6 3.6c.2.2.5.2.7 0L12 6.5"/>

</svg>

{{/vote}}

{{/with}}

 

 

Screenshot for the same:

 

 

5).  When you have done with those few steps, save and test.

 

6). Click on the vote sum area on the community post page.

 

 

 

 

 

If any confusion, do let me know :)

 

Thanks

Team Diziana

 

0


Will shut down voting on the entire community or just on the specific post that these steps are executed on?

0


image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

It's for all community posts if you want it only for one (specific post) then it's also possible with little bit of customization.

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post