Matt
Matt

Reputation: 15

Use PHP/Javascript to change text displayed in Disqus comments?

I have Disqus commenting system installed on my Drupal-based site. Is it possible to change some of the text in it through using PHP or JavaScript?

For example, I want to change the text "1 person likes this" to "+1". The number is clearly a variable, because it changes according to how many people actually clicked the "like button".

So another way to put what I want to do is; I want to change "x person likes this" to "+x".

Upvotes: 0

Views: 406

Answers (1)

George Cummins
George Cummins

Reputation: 28906

That text does not exist in the Disqus module for Drupal. Since it originates on the remote Disqus server, you will not be able to edit it directly.

You may be able to modify it using Javascript if you can locate the page element that contains the text:

var old_text = document.getElementById('element_that_contains_the_text').innerHTML;
document.getElementById('element_that_contains_the_text').innerHTML( '+' + old_text.split( ' ', 2 )[0] );

Note 1: innerHTML does not work consistently cross-browser, so you may achieve better results using jQuery's html().

Note 2: You will need to ensure that your code runs after the Discus JS code.

Upvotes: 1

Related Questions