Problems with <p> tag

Author Message

Mahesh Arvind

Friday 16 January 2004 8:19:15 pm

Hi,
I am using the shorten function to truncate the number of characters in article description to 100 characters. I am using the following code.

{$:item.data_map.resource_introduction.content.output.output_text|shorten(100)}

The output is enclosed with a <p> and </p> tag. But, when the description size is greater than 100, the text is shortened, but the </p> does not come along. If the size of description is less than 100 characters then the output is perfect, it has both <p> and </p> tag.

The real problem comes when there is a situation where I get something like this.

<p> Text desciption ... </p

The [More] link which comes next then does not have the hyperlink working in it.

The text is truncated like this. The shorten function should only truncate the description and not the paragraph tags. Is this a bug in Ez ? Does anyone has any idea why this is happening?

But when we use the code {$:item.data_map.resource_introduction.data_text|shorten(100)} the shorten function does not work.

Is there any way to avoid the <p> and </p> tags being generated by the Ez system.

Thanks.

Mahesh

Thanks & Regards
Mahesh

Marco Zinn

Saturday 17 January 2004 1:27:19 am

Hi,
well, you intro field is XML, so, depending on the content, you will run into more problems, when some HTML-Structure is not complete after 100 chars.
Option 1: Do not use an XML-Field, but a text field for the intro.
Option 2: Try to get rid of the HTML-Tags before you "shorten" the text. MAYBE the "wash" opertor will do it, but i'm not sure.
Try
{$:item.data_map.resource_introduction.data_text|wash|shorten(100)} and see, what happens. Look at the HTML-source of your page.
Note: If this works, it will remove all HTML-Tags and formatting (such as bold, links, tables).
The other option would be to enhance the "shorten" operator to keep track of open HTML-Tags and close them, before returning the result. But i think, the operator cannot do this and there is no such operator (yet).

Marco
http://www.hyperroad-design.com

Mahesh Arvind

Monday 19 January 2004 1:22:34 am

Hi Macro,

I had tried the wash operator, but it isn't producing the result. It translates the paragraph tags to someting like &gt &lt etc. The <p> tag itself is appearing in the webpage. The thing I needed was to somehow see that </P> doesnt come so that the [More] link doesn't get pushed to the next line. I achieved this by truncating the last four characters of the description which is </p> tag by using string handling functions.

Thanks

Mahesh

Thanks & Regards
Mahesh

Trond Hjelmaas

Monday 11 April 2005 3:36:27 am

Dear Mahesh,

I need to delete the <p> tag as well. If you happen to view this article still, would you mind to post an example of how you use the string function to delete the <p>?

Thanks in advance,
Trond

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

eZ debug

Timing: Jan 18 2025 22:31:31
Script start
Timing: Jan 18 2025 22:31:31
Module start 'layout'
Timing: Jan 18 2025 22:31:31
Module start 'content'
Timing: Jan 18 2025 22:31:32
Module end 'content'
Timing: Jan 18 2025 22:31:32
Script end

Main resources:

Total runtime0.8901 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 589.2422152.6094
Module start 'layout' 0.00700.0034 741.851639.4141
Module start 'content' 0.01040.8778 781.2656590.0547
Module end 'content' 0.88820.0019 1,371.320312.5000
Script end 0.8901  1,383.8203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4425160.0002
Check MTime0.00160.1786160.0001
Mysql Total
Database connection0.00080.094610.0008
Mysqli_queries0.828193.0300620.0134
Looping result0.00090.1042600.0000
Template Total0.854496.020.4272
Template load0.00230.255120.0011
Template processing0.852195.733220.4261
Template load and register function0.00010.012110.0001
states
state_id_array0.00130.147910.0013
state_identifier_array0.00120.131920.0006
Override
Cache load0.00190.2170370.0001
Sytem overhead
Fetch class attribute can translate value0.00110.125030.0004
Fetch class attribute name0.00100.110760.0002
XML
Image XML parsing0.00110.124130.0004
class_abstraction
Instantiating content class attribute0.00000.001670.0000
General
dbfile0.00100.1154220.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0005 secs