Forums / Developer / Problems with <p> tag

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