Extra <br /> tag while using linebreaks with paragraph

Author Message

John Smith

Monday 20 March 2006 6:24:17 am

If you enter a text with a linebreak you will get the following results:

<p>test<br />text<br /></p>

The issue is with the last <br /> in the example. It is completly unneeded..

Is it a bug, has anybody solved it?

Please help

Cheers

John Smith

Kirill Subbotin

Thursday 23 March 2006 1:34:31 am

It's a bug. We will try to fix it soon.

I've added a bug report http://ez.no/bugs/view/8028

John Smith

Friday 24 March 2006 6:16:48 am

hi Kirill,

Thanks for your reply. Mate I think you have solved the bug. Would it be possible to know the changes, so that i can update my version.

Cheers

Regards
John..

Kirill Subbotin

Monday 27 March 2006 1:13:01 am

Yes, here is the patch:

Modified: trunk/kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php
===================================================================
--- trunk/kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php	2006-03-24 11:26:45 UTC (rev 15292)
+++ trunk/kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php	2006-03-24 11:29:44 UTC (rev 15293)
@@ -341,8 +341,20 @@
 
         $sectionLevel = $currentSectionLevel;
         $class = $paragraph->attributeValue( 'class' );
+        $curChildIndex = 0;
+        $totalChildren = count( $paragraph->children() );
         foreach ( $paragraph->children() as $paragraphNode )
         {
+            $curChildIndex++;
+
+            if ( $curChildIndex == $totalChildren ) 
+            {
+              $this->LastParagraphChild = true;
+            }
+            else
+            {
+                $this->LastParagraphChild = false;
+            }
             $isBlockTag = false;
             $content =& $this->renderXHTMLTag( $tpl, $paragraphNode, $sectionLevel, $isBlockTag, $tdSectionLevel );
             if ( $isBlockTag === true )
@@ -1020,6 +1032,12 @@
                 $tpl->setVariable( 'content', $childTagText, 'xmltagns' );
                 $uri = "design:content/datatype/view/ezxmltags/$tagName.tpl";
 
+                //force rendering last line without <br> i.e. as plain text
+                if ( $tagName == 'line' && $this->LastParagraphChild ) 
+                {
+                    $uri = "design:content/datatype/view/ezxmltags/text.tpl";
+                }
+
                 $textElements = array();
                 include_once( 'lib/eztemplate/classes/eztemplateincludefunction.php' );
                 eZTemplateIncludeFunction::handleInclude( $textElements, $uri, $tpl, 'foo', 'xmltagns' );
@@ -1110,6 +1128,10 @@
 
     /// Contains the Nodes hashed by ID
     var $NodeArray = array();
+    
+    /// Contains boolean flag if current child is last among paragraph children
+    /// used when rendering last <line> tag.
+    var $LastParagraphChild = false;
 
     /// Array of parameters for rendering tags that are children of 'link' tag
     var $LinkParameters = array();

John Smith

Monday 27 March 2006 1:42:13 am

hi Kirill,

Thanks for your kind help. I just want to know whether this patch is applicable to ezpublish 3.6.1

I am using ez 3.6.1 at the moment.

Thanks in advance.

Cheers

John...

Kirill Subbotin

Monday 27 March 2006 2:02:50 am

Not sure about 3.6.1, may be, but most likely it should work with the latest 3.6.*

John Smith

Monday 27 March 2006 2:19:27 am

Thanks,

I have tried on ezpublish 3.6.1, it seems to be working.Obviously the line numbers are different what you said in your last reply.

Once again thanks for your kind help.

Cheers.

John...

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.