We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11838 ☆ A M B ☆
    • 79 Posts
    Hello,
    i would like to use this code :
    <?php
    /**
     * SimpleCleaner
     *
     * Can remove or replace unwanted tags and words in the content
     * by Paul Merchant
     *
     * Fire with the OnDocFormSave event
     */
     
    /* Modify the cleaners array to add more patterns and replacements */
    $cleaners = array(
       // Removes paragraph tags when they are directly surrounding a modx tag
       '~<p>(\r?\n|\s)?\[\[(.+?)\]\](\r?\n|\s)?</p>~' => '[[$2]]'
    );
    $content = $resource->get('content');
    foreach ($cleaners as $pattern => $replacement){
       $content = preg_replace($pattern,$replacement,$content);
    }
    $resource->set('content',$content);
    $resource->save();
    ?>

    to replate " & ' by
    & q u ot ;
    &
    & r s q u o ;
    especially in tags.

    How do i do that ? Someone could help ?

    Thanks [ed. note: hartus last edited this post 13 years, 8 months ago.]
      • 40447
      • 165 Posts
      We don't use modx tags within the content very often, but when we do it's often a pain. TinyMCE wraps them with <p> tags and can make some of the code ugly or even mess it up. Turning off the forced <p> tags isn't always easy or a good option.
      I thought I was the only one code fighting with TinyMCE - Not!
      Great idea about this cleaning away code.
      I remember Susan Otwell posted something great a while ago about keeping modx tags out of TinyMCE and only use TinyMCE for tags like <p> and <h> etc that are allowed for frontend editors. I still haven't figured that out how to do that. For example how do you keep your chunks, snippets, tv's out of the content. I hope Susan will reply on this.
        • 40447
        • 165 Posts
        Is this a good way to get content from one resource that is allowed to be edited by a frontend user and pull it into another resource that is allowed to be edited by a backend user ?

        <div id="content">
          <h1>[*longtitle*]</h1>
          [*content*]
        </div


        and then use

        $homeDoc = $modx->getDocumentObject('id',1);


        or use

        $array = $modx->getPageInfo($id,1,'content'); $content = $array['content'];