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
There may be another way to do it, but I usually turn of the rich text editor when working with chunks and snippet calls.
Yes, that’s what I do, but I can’t tell my colleagues or clients to do that, too.
-
☆ 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
});
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.
@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 ...
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
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>