We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I've tried many things to do that:

    entity_encoding : "raw", "names" or "numeric"
    did not help.
    preformatted : false
    verify_html : false
    apply_source_formatting : false
    entities : "160,nbsp,38,amp,34,quot,162,cent,8364,euro,163....
    cleanup: flase
    did not help neither.

    I would like
    <a href="url">
    to become
    <a href=& q u ot ;url& q u ot ;>
    in html code.

    I know it is not W3C valid, i know too that tiny mce might not be the best way to do that, i just ask if someone knows how to do that.

    I need to change every " and ' by
    & q u ot ;
    and
    & r s q u o ;
    before it goes in database.

    Do i have to use regex ? replace ? What kind of synthax should i use ?

    Thank you
      • 3749
      • 24,544 Posts
      If you put every href tag on a separate line, you could possibly check for 'href' with strstr() and then use str_replace(). Otherwise, you might be looking at a fairly difficult preg_replace().
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
      • Do you think that something like this could help ?

        $cleaners = array(
           '"' => '& q u ot ;'
        );
        $content = $resource->get('content');
        foreach ($cleaners as $pattern => $replacement){
           $content = preg_replace($pattern,$replacement,$content);
        }
        $resource->set('content',$content);
        $resource->save();
        ?>


        I just don't know instead of remove how to replace.... I can not put <a> on separate lines because linebreaks break my code as " does.
        I don't manage to apply replace filter on my content even with simple words like replace word1 by word2 OnDocFormSave event.
        Thanks [ed. note: hartus last edited this post 11 years, 3 months ago.]
          • 3749
          • 24,544 Posts
          That would replace every double quote on the page, not just the ones in hrefs. If you're going that route, str_replace() will be much faster:

          $content = str_replace('"', '& q u o t e', $content);


          Can you explain why you're doing this? There might be a much easier way to accomplish what you want.

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
          • Yes i need to replace every " in every tags and ' as well. I created a plugin with your code and tick OnDocFormSave but i can not get it working. I've tried few differents plugins but it is still the same, i must do something wrong but it seems to be so simple yet.

            I want to do that because i use javascript and modx's tv to display content with tabs (synopsis, presse, festival...) like this :

            http://aurorafilms.eskem-studio.com/its-all-in-lebanon.html

            but " and ' breaks my js tabs system and i want my customer to be able to add links and css styles. So for now i've replaced every " with '' manualy but it is not and option for tags because tinymce automaticaly add missing " in tags.

            So i've been trying to replace " directly in tinymce with thise code in \tinymce\jscripts\tiny_mce\tiny_mce_src.js:

            tinymce.EditorManager.init({
               preformatted : false
               verify_html : false,
               onchange_callback : function(inst){
                    var $inst = $('#'+inst.id);
                    $inst.val($inst.val().replace('"','"'));
               },
            });


            But i can not get it working neither, my only option for now is to insert <a> and css tags directly in database and never open back the page with modx backoffice because tiny mce will add " again.
              • 36926
              • 701 Posts
              Quote from: hartus at Jan 17, 2013, 10:37 AM

              I want to do that because i use javascript and modx's tv to display content with tabs (synopsis, presse, festival...) like this :

              How are you doing this with modx TV's. Do you have a different TV for each to. Or are you using a single wysiwyg TV that contains all the tabs.


              Are you just try to develop a system where the user can add tab as and when they need. If so using MIGX would be the way to go or you could use getResources and have the child documents as tabs of that page.



              • Thank you bennyb,

                I just need the 4 same tabs on every page. If one of the tv is empty so the tab do not display. My system works fine (except with quote, I know smiley ) and is very simple to use. But i feel like i'm so close to get what i want, everything is ready on this website. So before trying your system or anything else i juste would like to make this replace plugin working.

                Anyway, thank you very much, i might ask you more information on how to do that with Migx in few days wink
                  • 3749
                  • 24,544 Posts
                  How about doing the replace in the JS code, then reverse it (still in the JS) after you're done processing things?
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                  • So the solution for me was to display my tv's content in a hidden div in my template like this :

                    <div id="presse" style="display: none;">[[*presse]]</div>


                    and then to call my div's content like this in my javascript :

                    document.getElementById("presse").innerHTML,