Forums / General / use of shorten with attribute_view_gui
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
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.
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)}
Monday 15 September 2008 12:23:45 am
Hi,Thank you for everything, that's it, it works !!!!
Monday 15 September 2008 1:48:27 am
Hi, how can i now limit the xml attribute?
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)}
Monday 15 September 2008 4:08:31 am
Thank you, it works with XML attribute. Thanks Ivo Lukac !