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.