HomeHome  
  • WelcomeWelcome  
  • Events  
  • PublicationsPublications  
  • FAQFAQ  
  • SearchSearch  
  • MemberlistMemberlist  
  • UsergroupsUsergroups  
  • RegisterRegister  
  • Log inLog in  
  • You are not connected. Please login or register


    Replace post content with specific text

    avatar
    • *****


        Reputation : 11
        Registered on : 2014-04-25
        Posts : 153
        Love Fmcodes
      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

      avatar
      • **


          Reputation : 0
          Registered on : 2014-05-31
          Posts : 19
          Love Fmcodes
        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 :/



        Last edited by Nihil on Sat May 31, 2014 2:31 pm; edited 2 times in total

        avatar
        • *****


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

          avatar
          • Support Moderator

              Reputation : 8
              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.
            avatar
            • *****


                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

              avatar
              • **


                  Reputation : 0
                  Registered on : 2014-05-31
                  Posts : 19
                  Love Fmcodes
                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).

                avatar
                • Administrator

                    Reputation : 315
                    Registered on : 2012-02-22
                    Posts : 2362
                    School of codes courses: coming soon
                  Try adding this javascript
                  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

                  avatar
                  • *****


                      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 :)

                    avatar
                    • **


                        Reputation : 0
                        Registered on : 2014-05-31
                        Posts : 19
                        Love Fmcodes
                      Cool :)

                      Just be sure to know that if you post "Thankfull", it can replace your word :/.

                      avatar
                      • Administrator

                          Reputation : 315
                          Registered on : 2012-02-22
                          Posts : 2362
                          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

                        avatar
                        • *****


                            Reputation : 11
                            Registered on : 2014-04-25
                            Posts : 153
                            Love Fmcodes
                          still nothing.. :P

                          avatar
                          • *****


                              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...

                            avatar
                            • ****


                                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");
                                 });
                              });

                              avatar
                              • Support Moderator

                                  Reputation : 8
                                  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



                                FMCodes Support Moderator

                                I am very active now! Feel free to PM me anytime.


                                YOUR BANNER HERE
                                728x90
                                DMCA.com Protection Status
                                © PunBB | Contact | Report an abuse