Shorten on object body attribute content text .. odd behaviour

Author Message

Lo' F.

Sunday 07 November 2010 11:21:42 am

Hi there!

Here's another one!

There is a fetch statement which retrieves the content of a body attribute containing a picture.

Did that with another fetch of related objects, inside the main one, this way:

{def $items=fetch('content', 'tree', hash('parent_node_id', 2, .., 'class_filter_type', 'include', 'class_filter_array', array('article')))}
{foreach $itens as $item}
  {def $picts=fetch('content', 'related_objects', hash('object_id', $item.object_id))}
  {foreach $picts as pict}
    {if $pict.class_name|eq('Image')}
      {attribute_view_guy attribute=$pict.data_map.image image_class=small}
      {break}
    {/if}
  {/foreach}
  {$item.data_map.body.content.output.output_text|strip_tags()||shorten(300, '...')}
{/foreach}

Picture and body text are nicely displayed but...

The problem is: the text isn't made of the set number of chars but it varies in length, which is pretty strange.

It can't depend on the related picture, can it?

Anyone can help figure it out?

loredanaebook.it

Franck Magnan

Monday 08 November 2010 12:08:25 am

Hello Lo' F,

in your case, you put 2 "pipes" instead of one :

{$item.data_map.body.content.output.output_text|strip_tags()||shorten(300, '...')}

you may try to use only one "pipe" like this :

{$item.data_map.body.content.output.output_text|strip_tags()|shorten(300, '...')}

hope this helps

--
Developer at Open Wide

André R.

Monday 08 November 2010 1:59:42 am

Also note that there are extensions out there that does shorten a bit better on html output:

http://projects.ez.no/xmlwash

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Lo' F.

Friday 12 November 2010 12:14:20 pm

Hi Franck and Anrdre' and thanks for your reply.

"

...in your case, you put 2 "pipes" instead of one..

"

..just mistyped while reporting.. anyway...

Resolved the issue by activating wordCut extension (http://projects.ez.no/wordcut_extension) and replaced...

|shorten(300, '...')

with...

|word_cut(40)

loredanaebook.it

Steven E. Bailey

Saturday 13 November 2010 3:17:49 am

There is also http://projects.ez.no/smartshort

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Lo' F.

Saturday 13 November 2010 7:20:44 am

"

There is also http://projects.ez.no/smartshort

"

Good to know! Thank you Steven..

loredanaebook.it

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

Main resources:

Total runtime0.8742 sec
Peak memory usage4,096.0000 KB
Database Queries72

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 588.1719152.6563
Module start 'layout' 0.00690.0028 740.828139.5156
Module start 'content' 0.00970.8624 780.3438679.4688
Module end 'content' 0.87210.0020 1,459.812516.0938
Script end 0.8741  1,475.9063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4417160.0002
Check MTime0.00160.1790160.0001
Mysql Total
Database connection0.00130.153410.0013
Mysqli_queries0.791790.5682720.0110
Looping result0.00080.0926700.0000
Template Total0.840696.220.4203
Template load0.00230.264620.0012
Template processing0.838295.886620.4191
Template load and register function0.00020.017510.0002
states
state_id_array0.00120.139210.0012
state_identifier_array0.00090.101020.0004
Override
Cache load0.00200.2331450.0000
Sytem overhead
Fetch class attribute can translate value0.00090.107640.0002
Fetch class attribute name0.00140.1623100.0001
XML
Image XML parsing0.00520.590140.0013
class_abstraction
Instantiating content class attribute0.00000.0027120.0000
General
dbfile0.00420.4829350.0001
String conversion0.00000.000740.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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
2content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 37
 Number of unique templates used: 8

Time used to render debug report: 0.0002 secs