Forums / Setup & design / Shorten functionnality and listitem conflict

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Shorten functionnality and listitem conflict

Author Message

laurent le cadet

Friday 25 March 2005 1:25:09 am

Łukasz Serwatka

Tuesday 29 March 2005 1:36:49 am

Hi laurent,

Have you tried with wash() operator?

{$node.object.data_map.intro.content.output.output_text|wash(  xhtml )|shorten( 50 )}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

laurent le cadet

Tuesday 29 March 2005 4:26:29 am

Hi Lukasz,

Yes I tryied but I have a result like this

<p> My shorten text...

or

<p> My shorten t<br /...

Laurent

Bård Farstad

Tuesday 29 March 2005 4:39:30 am

Hi Laurent,

You should strip the tags if you want to use the shorten tag with XML content. Some info on how to do so can be found here:
http://www.ez.no/community/forum/developer/operator_to_strip_off_html_tags

Cheers,

--bård

Documentation: http://ez.no/doc

laurent le cadet

Tuesday 29 March 2005 7:12:26 am

Hi Bård,

That's what I did previously.
I override template.ini in the override directory.
template.ini.append.php :

<?php /* #?ini charset="iso-8859-1"?

PHPOperatorList[]
PHPOperatorList[striptags]=strip_tags

*/ ?>

and add in mysite/override/templates/listitem/article.tpl

<div class="attribute-short">     {$node.object.data_map.intro.content.output.output_text|striptags|shorten( 50 )}
</div>

It works fine but without formatting text or image in the shorten string.

Laurent.

laurent le cadet

Tuesday 29 March 2005 8:23:42 am

in fact with this code

{$node.object.data_map.intro.content.output.output_text|striptags|shorten( 50 )}

it cut the string but preserve formatters:

<div class="attribute-short">
<p>
Le projet de réaménagement du club house p...
</div>

What I understand that the |wash operator render the <p> tag as text but didn't remove it.

Bård Farstad

Thursday 31 March 2005 3:13:58 am

Laurent,

if you have XML text it's hard to convert it to a limited number of characters without removing the formatting. So you should just use the strip tags followed by a shorten operator. Formatting and images will be gone, just the plain text is left.

You are correct, the wash() operator does only convert HTML specific characters like <, > and & to &gt; and so on.

--bård

Documentation: http://ez.no/doc

laurent le cadet

Thursday 31 March 2005 4:17:10 am

thanks.

Laurent.