We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38060
    • 29 Posts
    This is an issue, which drives me nuts since quite a while:

    I have chunks containing elements which you can not wrap in <p>-elements - eg.
    <div>...</div>
    . When I save the code, TinyMCE wraps these chunks in <p>-elements, most of the time, but today I encountered a case where it does not do it. I have not figured out the rule why it does not do it.

    So till today, I always added inside of the chunks a closing </p> at the beginning and an opening <p> at the end to create empty <p>-elements. I just run a little plugin to strip those
    <p></p>
    out.

    I am sure, there is a clean and reliable way to tell TinyMCE not to process a line, without bloating the code with <div>-elements.

    Anybody any ideas? Thank you!
      • 13226
      • 953 Posts
      The following will hopefully help you.

      In the manager:

      1. Go to: Manage Elements => Plugins
      2. Select TinyMCE
      3. Click Configuration tab
      4. Look for "Custom Parameters"
      5. Add: forced_root_block:0

      Remember that custom parameters are comma seperated

      You can read up about it here.

      You may also want to add other custom parameters such as extended_valid_elements e.g.
      extended_valid_elements:"div[id|class|style|title]"


      I have also used a custom plugin in the past:

      plugin name: ParseTinyMice
      plugin system events: OnParseDocument
      plugin code:
      $e = &$modx->Event;
      switch ($e->name) {
      case 'OnParseDocument':
          $replace = array(
          '<p>[!'    => '[!',
          '!]</p>'   => '!]',
          '<p>[['    => '[[',
          ']]</p>'   => ']]',
          '<p>{{'    => '{{',
          '}}</p>'   => '}}'
          );
          $this->documentOutput = str_replace(array_keys($replace), array_values($replace), $this->documentOutput);
          break;
          default: '';
          return;
      }


      I don't offer support for the plugin - simply because its not realy needed when the custom parameters are used and I personally no-longer use it, but it may help someone

      It has helped me in the past with old client sites, so I haven't deleted it from my Evo back-ups yet smiley

      Cheers [ed. note: iusemodx last edited this post 13 years, 1 month ago.]
        • 38060
        • 29 Posts
        Wow, your plugin is really cool. way better than my solution!

        Thank you. This will help me a lot!
          • 13226
          • 953 Posts
          Quote from: holgermeier at Aug 14, 2013, 07:57 PM
          Wow, your plugin is really cool. way better than my solution!

          Thank you. This will help me a lot!

          No problem smiley - but I would still add the custom settings