Page 1 of 1

FCKeditor creates emtpy paragraph

Posted: Tue 24. Jun 2008, 19:54
by beat
Hi All

I have a problem with FCKeditor I need to solve soon. In PHPWCMS 1.3.9 FCKeditor creates in each empty Field a empty paragraph. I've disabled it with

Code: Select all

FCKConfig.FillEmptyBlocks	= false ;
but FCKeditor is anyway placing a <p>&160;</p>.

This is absolutley not user Friendly. Is there any solution to this problem?

Thanks for your help.

Re: FCKeditor creates emtpy paragraph

Posted: Tue 24. Jun 2008, 20:58
by pepe
Die Einstellung war ja schon mal richtig!

Lösche mal den Cache und starte doch mal deine Anwendung komplett neu...

Ein neuer Aufruf des Editors alleine reicht nicht aus!
Und versuch damm mal einen neuen CP... dann klappt das auch!

Re: FCKeditor creates emtpy paragraph

Posted: Sun 17. Aug 2008, 06:51
by santscho
And you have to open all articles/CPs which are allready done. then you have to switch into the html mode of your fckeditor and delete the unwanted paragraph. Save the CP/Article and the problem should be solved. PHPWCMS will not remove the empty paragraphs for you.

Special in the Summary field ouf your article header.... there are mostly empty paragraphs :-(

Re: FCKeditor creates emtpy paragraph

Posted: Sun 17. Aug 2008, 09:07
by Oliver Georgi
If you have such and are not willing to touch all content place a small script in frontend_render, maybe name it replace_all.php:

Code: Select all

<?php
// Search and replace
$_search = array(	 '<br>',
							'<p>&nbsp;</p>', 
							'<p><p>', 
							'</p></p>', 
							'...', 
							' - ', 
							"<br />\r\n&nbsp;</p>",
							'<p><br />',
							'<p>&160;</p>'
							);
$_replace = array(	'<br />',
							'', 
							'<p>', 
							'</p>', 
							'&#8230;', 
							' &#8211; ', 
							'</p>',
							'<p>',
							''								
							);

$content['all'] = str_replace($_search, $_replace, $content['all']);
?>
And

Code: Select all

FCKConfig.FillEmptyBlocks = false;
is the default setting since some revisions.

Oliver

Re: FCKeditor creates emtpy paragraph

Posted: Thu 10. Sep 2009, 21:03
by santscho
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>&nbsp;</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>&nbsp;</p>',
                     '<div class="article_summary"><p>&#160;</p></div>',
                     '<p><p>', 
                     '</p></p>', 
                     '...', 
                     ' - ', 
                     "<br />\r\n&nbsp;</p>",
                     '<p><br />',
                     '<p>&160;</p>'
                     );
$_replace = array(   '<br />',
                     '', 
                     '', 
                     '<p>', 
                     '</p>', 
                     '&#8230;', 
                     ' &#8211; ', 
                     '</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>&nbsp;</p>',
                     '<div class="article_summary"><p>&#160;</p></div>',
                     '<p><p>', 
                     '</p></p>', 
                     '...', 
                     ' - ', 
                     "<br />\r\n&nbsp;</p>",
                     '<p><br />',
                     '<p>&160;</p>'
                     );
$_replace = array(   '<br />',
                     '', 
                     '<div class="article_summary_empty"></div>', 
                     '<p>', 
                     '</p>', 
                     '&#8230;', 
                     ' &#8211; ', 
                     '</p>',
                     '<p>',
                     ''                        
                     );

$content['all'] = str_replace($_search, $_replace, $content['all']);
?>