Here an extension of Oliver's script above.
In case the empty paragraph is placed in a div container which has a border or is filled with color/background image, the script will only remove <p> </p>. An empty div will remain with all its props. Means, you will get an unwanted line or color bar even you don't want it. Therefore, you have to advise the script to remove the whole div container.
In my example, I remove the article summary with an empty paragraph.
Code: Select all
<?php
// Search and replace
$_search = array( '<br>',
'<p> </p>',
'<div class="article_summary"><p> </p></div>',
'<p><p>',
'</p></p>',
'...',
' - ',
"<br />\r\n </p>",
'<p><br />',
'<p>&160;</p>'
);
$_replace = array( '<br />',
'',
'',
'<p>',
'</p>',
'…',
' – ',
'</p>',
'<p>',
''
);
$content['all'] = str_replace($_search, $_replace, $content['all']);
?>
In case you want to remove the graphical elements of a div container, but not its padding (eg. to keep the distance between subtitle and Content Parts), you can replace the unwanted div with an other div.
So I duplicate the css class ".article_summary" in my .css, remove all the graphical attributes (borders, fillings) and keep only the padding, rename the class (eg. ".article_summary_empty") and advice phpwcms to replace:
Code: Select all
<?php
// Search and replace
$_search = array( '<br>',
'<p> </p>',
'<div class="article_summary"><p> </p></div>',
'<p><p>',
'</p></p>',
'...',
' - ',
"<br />\r\n </p>",
'<p><br />',
'<p>&160;</p>'
);
$_replace = array( '<br />',
'',
'<div class="article_summary_empty"></div>',
'<p>',
'</p>',
'…',
' – ',
'</p>',
'<p>',
''
);
$content['all'] = str_replace($_search, $_replace, $content['all']);
?>