use of shorten with attribute_view_gui

Author Message

Jacks JNK

Saturday 13 September 2008 2:03:06 am

This code does not work, it is there a mistake somewhere?

   {attribute_view_gui attribute=$article.data_map.body|shorten(100)}
 

Skype : jacks_ngala

Carlos Revillo

Saturday 13 September 2008 2:42:56 am

i think attribute_view_gui needs and attribute. $article.data_map.body|shorten(100) is not an attribute, only $article.data_map.body is.

so, you better do an override for that attribute view, and do the |shorten(100) on that template.

then in your "main" template it will work if you do {attribute_view_gui =$article.data_map.body}

hope it helps.

André R.

Saturday 13 September 2008 2:45:46 am

Carlos got it partly right, there is one more issue with this.
You are trying to shorten a xml attribute with a string operator, it will just mess up your output. There is a contribution somwhere (on this site or projects) by Xavier that shortens xml content.

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

Ivo Lukac

Saturday 13 September 2008 3:07:08 am

Most easy way to do this is to map strip_tags PHP operator to ez operator and use it before shorten.

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Jacks JNK

Saturday 13 September 2008 3:36:09 am

Hi ,
- thanks Carlos Revillo, but i dont andextand you well !

- André R, my body is not an XML attribut. I have my hown class with "body" as attibute.

Skype : jacks_ngala

Ivo Lukac

Saturday 13 September 2008 3:54:38 am

If your body attribute is just simple text then instead your code just use this:

{$article.data_map.body.content|shorten(100)}

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Jacks JNK

Monday 15 September 2008 12:23:45 am

Hi,
Thank you for everything, that's it, it works !!!!

Skype : jacks_ngala

Jacks JNK

Monday 15 September 2008 1:48:27 am

Hi, how can i now limit the xml attribute?

Skype : jacks_ngala

Ivo Lukac

Monday 15 September 2008 3:00:16 am

Put this in your template.ini.append.php:

[PHP]
PHPOperatorList[striptags]=strip_tags

and than use it like this for XML attribute:

{$article.data_map.xml_attribute.content.output.output_text|striptags|shorten(100)}

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Jacks JNK

Monday 15 September 2008 4:08:31 am


Thank you, it works with XML attribute. Thanks Ivo Lukac !

Skype : jacks_ngala

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 31 2025 06:27:54
Script start
Timing: Jan 31 2025 06:27:54
Module start 'layout'
Timing: Jan 31 2025 06:27:54
Module start 'content'
Timing: Jan 31 2025 06:27:54
Module end 'content'
Timing: Jan 31 2025 06:27:54
Script end

Main resources:

Total runtime0.0287 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.0061 588.1484151.2109
Module start 'layout' 0.00610.0035 739.359436.6484
Module start 'content' 0.00960.0173 776.0078102.2500
Module end 'content' 0.02700.0017 878.257845.9922
Script end 0.0287  924.2500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00248.1879140.0002
Check MTime0.00113.8617140.0001
Mysql Total
Database connection0.00082.779910.0008
Mysqli_queries0.003813.048330.0013
Looping result0.00000.076310.0000
Template Total0.00113.910.0011
Template load0.00093.144910.0009
Template processing0.00020.734210.0002
Override
Cache load0.00062.102110.0006
General
dbfile0.006422.436680.0008
String conversion0.00000.027440.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