Hi, i want to use a js code which replaces the content of the post that a user wrote with another one. if someone writes 'thanks' as post at any topic of my forum, i want to replace and say 'thank you very much'. how can i do that? thanks
Replace post content with specific text

J0k3R^
*****
- Reputation : 11
Registered on : 2014-04-25
Posts : 153
Love Fmcodes
#1 - Posted on Sat May 31, 2014 5:14 am

Invité
- Guest
Hi J0k3R^
You don't need JS to do this :)
Here are some screenshots (the forum used for the screenshot is in French but I think it works the same way)
Admin panel > General > Censure


You just add your word and the replacement and it will be OK ^__^
EDIT : You need to put "Thank*" and "Thank you very much". Actually it won't work with the same words :/
You don't need JS to do this :)
Here are some screenshots (the forum used for the screenshot is in French but I think it works the same way)
Admin panel > General > Censure


You just add your word and the replacement and it will be OK ^__^
EDIT : You need to put "Thank*" and "Thank you very much". Actually it won't work with the same words :/
Last edited by Nihil on Sat May 31, 2014 2:31 pm; edited 2 times in total
#2 - Posted on Sat May 31, 2014 1:14 pm

J0k3R^
*****
- Reputation : 11
Registered on : 2014-04-25
Posts : 153
Love Fmcodes
why i get this error?


#3 - Posted on Sat May 31, 2014 1:57 pm

ddoesmc
- Support Moderator
- Reputation : 9
Registered on : 2014-03-11
Posts : 299
Helping on the forum
So this is what the warning is telling you, if you put "Thanks" as the censored word you can not include "Thank,Thanks" etc. in the word you want it to come out to be. This may be a bit unclear.

FMCodes Support Moderator
I am very active now! Feel free to PM me anytime.
#4 - Posted on Sat May 31, 2014 2:00 pm

J0k3R^
*****
- Reputation : 11
Registered on : 2014-04-25
Posts : 153
Love Fmcodes
ah i understood. but why they do that? :/ i needed to replace thank you with thank you very much xD
#5 - Posted on Sat May 31, 2014 2:24 pm

Invité
- Guest
Juste write : Thank* for the word (add the * at the end) :)
This way it will change thank and all other words starting by thank ^^ (including thanks).
This way it will change thank and all other words starting by thank ^^ (including thanks).
#6 - Posted on Sat May 31, 2014 2:30 pm

Niko
- Administrator
- Reputation : 319
Registered on : 2012-02-22
Posts : 2366
School of codes courses: coming soon
Try adding this javascript
it will replace thanks to thank you very much (only if it's thanks, with Thanks it won't work)
- Code:
$(function() {
var c = document.querySelectorAll('.entry-content')
for (i=0; i<c.length; i++) {
c[i].innerHTML = c[i].innerHTML.replace(/thanks/g,'thank you very much');
}
});
it will replace thanks to thank you very much (only if it's thanks, with Thanks it won't work)

Niko wants you in the team Guest
Community manager and Administrator at Forumattivo.com
#7 - Posted on Sat May 31, 2014 2:43 pm

J0k3R^
*****
- Reputation : 11
Registered on : 2014-04-25
Posts : 153
Love Fmcodes
Niko your code didnt work.
Nihil thank u, im using this and it works.
my problem is solved unless Niko got an alternative js :)
Nihil thank u, im using this and it works.
my problem is solved unless Niko got an alternative js :)
#8 - Posted on Sat May 31, 2014 2:49 pm

Invité
- Guest
Cool :)
Just be sure to know that if you post "Thankfull", it can replace your word :/.
Just be sure to know that if you post "Thankfull", it can replace your word :/.
#9 - Posted on Sat May 31, 2014 2:55 pm

Niko
- Administrator
- Reputation : 319
Registered on : 2012-02-22
Posts : 2366
School of codes courses: coming soon
ops
- Code:
$(document).ready(function(){
var c = document.querySelectorAll('.entry-content')
for (i=0; i<c.length; i++) {
c[i].innerHTML = c[i].innerHTML.replace(/thanks/g,'thank you very much');
}
});

Niko wants you in the team Guest
Community manager and Administrator at Forumattivo.com
#10 - Posted on Sat May 31, 2014 2:57 pm

J0k3R^
*****
- Reputation : 11
Registered on : 2014-04-25
Posts : 153
Love Fmcodes
still nothing.. :P
#11 - Posted on Sat May 31, 2014 5:42 pm

J0k3R^
*****
- Reputation : 11
Registered on : 2014-04-25
Posts : 153
Love Fmcodes
as u see Niko, u tried it yourself and didnt work :)
(this js was also affecting other js codes)
but its okey if we cant do something for this, i will use the thing from the "General" tab...
(this js was also affecting other js codes)
but its okey if we cant do something for this, i will use the thing from the "General" tab...
#12 - Posted on Sun Jun 01, 2014 6:28 pm

ionuz
****
- Reputation : 4
Registered on : 2012-05-05
Posts : 58
Try.
- Code:
$(function() {
$('.entry-content').each(function(a, c) {
c.innerHTML=c.innerHTML(/your words/i, "replace text");
});
});
#13 - Posted on Mon Jun 02, 2014 7:36 pm

ddoesmc
- Support Moderator
- Reputation : 9
Registered on : 2014-03-11
Posts : 299
Helping on the forum
Hello,
As anyone replied to this topic after 15 days from the latest comment's date, the problem is considered solved or abandoned.
This topic is locked and moved to the appropriate section, thanks for the opening of another topic, of course be care of Respecting the rules. You can ask to open this topic again sending a private message to a team member
See you on fmcodes
As anyone replied to this topic after 15 days from the latest comment's date, the problem is considered solved or abandoned.
This topic is locked and moved to the appropriate section, thanks for the opening of another topic, of course be care of Respecting the rules. You can ask to open this topic again sending a private message to a team member
See you on fmcodes

FMCodes Support Moderator
I am very active now! Feel free to PM me anytime.
#14 - Posted on Wed Jun 18, 2014 1:58 am
|
|