We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10313
    • 375 Posts
    Hello,

    since my beginnig of work with MODx, I wonder how it would be possible to avoid <p></p> tags around chunk or snippet calls that are placed into the content.

    Usually I use TinyMCE for editing the content. But TinyMCE wraps each paragraph with appropriate tags. For example: I have some paragraphs of text. I want to place a gallery between two of them. So I hit enter, type [tt]{{gallery}}[/tt] and hit enter again, continuing with the next paragraph.

    This results in [tt]<p>{{gallery}}</p>[/tt]. Wich in turn results in a DIV or UL within a P wich is forbidden. I am a web devolper, so I know how to help myself (don’t use TinyMCE, for example). But my customers or even my colleagues do not know anything about HTML. How can I help them in this situation?

    Any ideas very much appreciated.

    Greetings
    Martin
      • 8609
      • 607 Posts
      There may be another way to do it, but I usually turn of the rich text editor when working with chunks and snippet calls.
        • 10313
        • 375 Posts
        Yes, that’s what I do, but I can’t tell my colleagues or clients to do that, too.
          • 10487 MODX Staff
          • 1,535 Posts
          There’s a plugin setting for TinyMCE that controls that - I just can’t remember what it is. Maybe someone else can point you in the right direction (and if not, I’ll post back with it shortly)

          EDIT: Here we go, I believe this should help: http://modxcms.com/forums/index.php/topic,44734.msg266886.html#msg266886
            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Theoretically you should be able to put a custom parameter in the TinyMCE configuration doing something with the forced_root_block = false parameter.
            http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/forced_root_block
            So if you really really must use BR elements for some odd reason then set this in your init code:

            tinyMCE.init({
            forced_root_block : false,
            force_br_newlines : true,
            force_p_newlines : false
            });
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 5340
              • 1,624 Posts
              1. Select the snippet text and choose div instead of p
              2. Make a small Textarea TV callled Bottom or SnippetCall and place it under the [*content*] tag in the template.
                • 10313
                • 375 Posts
                @Susan: If I do that, do I have to select "paragraph" formatting manually for copy text?

                My problem is that I invest so much time to produce validating web pages, but the client just enters some text and all validation is gone ...
                  • 4041
                  • 788 Posts
                  Create a new plugin with the following code, making sure to check "OnParseDocument" on the event tab.

                  <?php // only here for styling and will break the plugin
                  $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;
                  }


                  Hope that helps smiley
                    xforum
                    http://frsbuilders.net (under construction) forum for evolution
                    • 27672
                    • 168 Posts
                    when in the RTE, pressing "ctrl+8" will wrap a <div> around the current line instead of a <p>.

                    on a related note (in case anyone does not know this), pressing "ctrl+1", "ctrl+2", "ctrl+3", ... "ctrl+6" will wrap <h1>, <h2>, <h3>, <h4>, <h5>, <h6> and "ctrl+7" will wrap a <p>
                      • 36404
                      • 307 Posts
                      hi,

                      @furyDE, sincerely, except if you want your clients to be allowed to put you chunks or call your snippets wherever they want, what i feel the best solution in this case (and the one i use...) is to prepare a peculiar template that has the chunk (or snippet call) in it, this way they only have to enter content in TVs, native content one or your personal ones

                      @slush puupie, there is also a very easy way to do this without having to memorize shortcuts, open the html tab and change that by hand smiley but i think that furyDE is looking for a solution for non coding or non dev people who are not expected to know what p, h or div exactly are... like clients very often do not smiley

                      have swing
                        réfléchir avant d'agir