Skip to content

Instantly share code, notes, and snippets.

@pepebe
Created November 15, 2013 13:57
Show Gist options
  • Select an option

  • Save pepebe/7484664 to your computer and use it in GitHub Desktop.

Select an option

Save pepebe/7484664 to your computer and use it in GitHub Desktop.
Remove p around modx tags used inside a tinymce rte field
<?php
/*
plugin to remove p arround modx tags in tinymce
author: breezer
event: OnParseDocument
*/
$eventName = $modx->event->name;
switch ($eventName)
{
//case 'OnParseDocument':
case 'OnWebPagePrerender':
//case 'OnLoadWebDocument':
$replace = array(
'<p>[[!' => '[[!'
,']]</p>' => ']]'
,'<p>[[*' => '[[*'
,']]</p>' => ']]'
,'<p>[[#' => '[[#'
,']]</p>' => ']]'
,'<p>[[$' => '[[$'
,']]</p>' => ']]'
//,'<p>' => '<div>'
//,'</p>' => '</div>'
,'<p><div' => '<div'
,'</div></p>' => '</div>'
);
$content = $modx->resource->_output; // get a reference to the output
$newContent = str_replace(
array_keys($replace)
,array_values($replace)
,$content
);
$modx->resource->_output = $newContent;
break;
default:
break;
}
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment