How to change vote text in Community | Community
Skip to main content

How to change vote text in Community

  • March 16, 2016
  • 5 replies
  • 0 views

Hi lovely Zendesk community

I've made some changes to the appears of our voting buttons in our Community, as users were getting confused with the up and down arrows.  I've also used the 'label' option to get the 'x out of y' bit, and added some script in to change the text from 'found this helpful' to 'liked this'

This works really well initially, but unfortunately when you vote on the post, the label refreshes for the new count and so reverts to the old wording.  Is there a way that I can either change the text without using a script, or get a script to run again once the value has changed?

Thanks,

Ola

This topic has been closed for replies.

5 replies

  • March 16, 2016

Hi Ola,

Adding this code in the theme editor Article page will do the trick:

<script>
$( document ).ready(function() {
change_text = function(){
str = $('.article-vote-label').html();
str = str.replace('found this helpful','liked it');
$('.article-vote-label').html(str);
};
change_text();
$('.article-vote-controls').on('click',function(){
var ivl_count=0;
ivl = setInterval(function(){
change_text();
console.log('x');
if (++ivl_count === 40) {window.clearInterval(ivl);}
},25)
});
});
</script>

There is no fully browser-compatible event that can catch span text change.

Therefore, the solution I found is to use SetInterval function with very short interval (25ms) and long enough time to win the race of changing the text after zendesk modifies the label.

The text may flicker once after you hit the vote button, but most often it won't.

I hope that helps,

Tal


  • Author
  • March 21, 2016

Hi Tal

Thank you so much!  I made a couple of changes to account for using a community post instead of an article, but it has worked perfectly.

Ola


  • July 26, 2016

Hi Tal,  
I hope it is ok to add to this post.  On our Community Post page the arrows for voting do not render on the page.  You can hover them and the function works though.  I ran across this article and actually like the idea of Like and Dislike buttons better.  Would you mind guiding me with a little more detail on how to make this change?

Thanks!


  • February 12, 2021

We have added this for articles, but I cannot figure out how to make it work for community posts. Any help would be greatly appreciated


Brett13
  • Community Manager
  • February 18, 2021

Hey Robert,

You'll want to take a look at our available helpers for the Help Center here: Help Center - Helpers. According to our documentation, you should be able to use vote helper in within the following:

I've also added your question to our Weekly Digest to see if anyone else can help point you in the right direction regarding the necessary code.

I hope this helps!