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.

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 19 2025 04:24:06
Script start
Timing: Jan 19 2025 04:24:06
Module start 'layout'
Timing: Jan 19 2025 04:24:06
Module start 'content'
Timing: Jan 19 2025 04:24:06
Module end 'content'
Timing: Jan 19 2025 04:24:06
Script end

Main resources:

Total runtime0.0215 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 589.2891152.6406
Module start 'layout' 0.00680.0029 741.929739.4766
Module start 'content' 0.00970.0098 781.406397.4922
Module end 'content' 0.01950.0021 878.898442.3047
Script end 0.0215  921.2031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002812.7973140.0002
Check MTime0.00135.9294140.0001
Mysql Total
Database connection0.00104.771910.0010
Mysqli_queries0.004018.733330.0013
Looping result0.00000.074110.0000
Template Total0.00167.510.0016
Template load0.00104.484110.0010
Template processing0.00062.971310.0006
Override
Cache load0.00073.031110.0007
General
dbfile0.00031.304780.0000
String conversion0.00000.027740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs