Forums / Install & configuration / Patch: Recognise line feeds in XML text fields

Patch: Recognise line feeds in XML text fields

Author Message

Bruce Morrison

Monday 10 February 2003 11:24:39 pm

I've created and submitted a patch to recognise linefeeds in XML text fields and render these as <br /> in the final output.

It is availiable at
http://developer.ez.no/bug/bugview/1870/

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Arash Molavi

Monday 10 February 2003 11:51:12 pm

> I've created and submitted a patch to recognise linefeeds in
> XML text fields and render these as <br /> in the
> final output.
>
> It is availiable at
> http://developer.ez.no/bug/bugview/1870/

Sorry.. feel stupid, but where should it go?

Bruce Morrison

Tuesday 11 February 2003 4:41:25 pm

> > I've created and submitted a patch to recognise linefeeds
> in
> > XML text fields and render these as <br /> in the
> > final output.
> >
> > It is availiable at
> > http://developer.ez.no/bug/bugview/1870/
>
> Sorry.. feel stupid, but where should it go?

The patch if actually a "patch" file - you need to apply it to a clean copy of RC2. If you have not done this before it would probally be easier to do it by hand.

There are 2 files that require editing in
kernel/classes/datatypes/ezxmltext/

Firstly ezsimpifiedxmlinput.php

after line 236 add the line
$paragraph =& preg_replace( "#\n#", "<br />", $paragraph );

so this section now looks liike

foreach ( $paragraphArray as $paragraph )
{
if ( trim( $paragraph ) != "" )
{
# BPM add <br / > tags for single newlines 20030211 15:09
$paragraph =& preg_replace( "#\n#", "<br />", $paragraph );
$sectionData .= "<paragraph>" . trim( $paragraph ) . "</paragraph>\n";
}
}

at around line 710
add the line
case 'br' :

so this section now looks like
case 'tr' :
case 'td' :
case 'paragraph' :
// BPM 20030211 15:21
case 'br' :
{
}break;

In file ezxhtmloutput.php

at around line 357 add the line

case 'br' :

so this section now looks like
// normal content tags
case 'emphasize' :
case 'strong' :
#BPM 20030211 13:36
case 'br' :
{

Hope this helps
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Jan Borsodi

Thursday 13 February 2003 6:08:26 am

> I've created and submitted a patch to recognise linefeeds in
> XML text fields and render these as <br /> in the
> final output.
>
> It is availiable at
> http://developer.ez.no/bug/bugview/1870/

This patch will break the XML format since it introduces a new tag br which will not be supported by the standard eZ publish format.
New tags such as this must be stored as a custom tag, you should create a new input handler and output viewer for XML if you want to preserve newlines in this way.
The next release features support for xml input/output handlers in extensions which should be used for this feature.

I also recommend not using a single br tag(as stored format), it's not a structured tag but rather a visual processing instructions. A better solution is to use a line tag(as custom tag) which wraps around the text which should be on a line.
<line>this is some text</line>
vs
this is some text<br/>

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Brendan Pike

Thursday 13 February 2003 7:19:47 am

Slightly off topic, but does anyone know if there is an actual page break either in the code or planned for yet?

i.e. So you can break a long article into muliple pages like the <page> tag did in 2.2.x

www.dbinformatics.com.au

We are always interested in hearing from experienced eZ PHP programmers and eZ template designers interested in contract work.

Bruce Morrison

Thursday 13 February 2003 2:41:17 pm

Hi Jan

Thanks for the info.

> > I've created and submitted a patch to recognise linefeeds
> in
> > XML text fields and render these as <br /> in the
> > final output.
> >
> > It is availiable at
> > http://developer.ez.no/bug/bugview/1870/
>
> This patch will break the XML format since it introduces a
> new tag br which will not be supported by the standard eZ
> publish format.

I guess this raises some questions.

Will the eZ team be adding the ability to insert line breaks (not paragraph breaks) into the core program (It seems that this will not be the case from your message)?

Is the DTD that ezPublish is using availiable? Is it based on any existing standards?

> New tags such as this must be stored as a custom tag, you
> should create a new input handler and output viewer for XML
> if you want to preserve newlines in this way.

I would have though that this would be a very common requirment. We are currently developing a number of sites using eZpublish3 and on all occasions clients asked for this ability. Thay have ben quite confused that it is not there. (it was in ezPublish 2 I think?)

> The next release features support for xml input/output
> handlers in extensions which should be used for this
> feature.
>
> I also recommend not using a single br tag(as stored
> format), it's not a structured tag but rather a visual
> processing instructions. A better solution is to use a line
> tag(as custom tag) which wraps around the text which should
> be on a line.
> <line>this is some text</line>
> vs
> this is some text<br/>

If I modify the patch to work in the way you suggest would it then be considered for addition to the core distribution?

This is one feature that needs to be available without the need for data entry staff to enter tags. i.e. it needs to be automatically handled by ezpublish.

On a related note - will there be a desktop version availiable for eZ Publish3 and if so, is there a time-frame on it's availability?

Thanks
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Jan Borsodi

Monday 17 February 2003 7:11:13 am

> Slightly off topic, but does anyone know if there is an
> actual page break either in the code or planned for yet?
>
> i.e. So you can break a long article into muliple pages like
> the <page> tag did in 2.2.x

Page breaks, like line breaks, are very layout specific and will not be supported by the eZXML datatype.
For now I can recommend using two article classes, one that has the intro etc. which works like a folder, then an Article Page class which contains one page of the article. Create the article pages as children of the article holder and you'll get the wanted functionality.

Another way is to program a custom XML output handler, it could for instance use the top level sections as the pages. Right now it's not possible to add custom url elements so it's not 100% possible yet to detect which "page" you are on.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.

Dan Zembrosky

Monday 10 March 2003 7:04:33 pm

this batch didnt do anything for me, didnt even show up in html output.