Author
|
Message
|
kavi kavi
|
Tuesday 23 January 2007 6:32:11 am
Hi everybody !
What's wrong with my code ?!
$item.object.data_map.intro.content.output.output_text is working without |shorten(100). Is shorten is incompatible with $item ?!
{let nodes=fetch( 'content', 'list', hash( 'parent_node_id', 100,
'limit', 3,
'sort_by', array( 'published', false() ) ))}
{foreach $nodes as $item}
<li class="article_atg">
<h1><a href="{$item.url}" title="titre">{$item.name}</a></h1>
<a href="{$item.url}" title="titre"><img src=""></img></a>
<p>
{def $mon_intro=$item.object.data_map.intro.content.output.output_text|shorten(100)}
<a href={$item.url} title="Lien vers : {$item.name}">{$mon_intro}</a>
</p>
</li>
{/foreach} {/let} kavi
|
Betsy Gamrat
|
Tuesday 23 January 2007 4:24:23 pm
kavi, I would try
{def $mon_intro=$item.object.data_map.intro.content.output|shorten(100)}
and
{def $mon_intro=$item.object.data_map.intro.content|shorten(100)}
|
Xavier Dutoit
|
Tuesday 23 January 2007 11:56:19 pm
Hi, You will have problem if your attribute is a xml block (or if it contains any html code), as it can cut it between the open and close tag. I wrote an extension to take care of that problem, not 100% sure about the api, but will put it soon in the svn if you're interested. X+
http://www.sydesy.com
|
kavi kavi
|
Wednesday 24 January 2007 1:20:33 am
Hi xavier! I'm interested on your code. I'll see it... I've find a solution but not the best i think...
Here is my code :
{let nodes=fetch( 'content', 'list', hash( 'parent_node_id', 100,
'limit', 3,
'sort_by', array( 'published', false() )))}
{foreach $nodes as $item}
<li class="article">
<h1><a href="{$item.url}" title="Lien vers : {$item.name}">{$item.name}</a></h1>
<p>
{def $mon_intro=$item.object.data_map.intro.content.output.output_text
$tab=$mon_intro|explode(' ')
$nb=$tab|count()
$tab1=$tab|extract(0,20 )}
<a href={$item.url} title="Lien vers : {$item.name}">{$tab1|implode(' ')}...</a>
</p>
</li> {/foreach}
Thanks kavi
|
Xavier Dutoit
|
Wednesday 24 January 2007 2:36:29 am
Hi, Funny solution, wouldn't have tought about it. Bravo ! My extension let you keep some tags (eg, a b i) and truncate it. Moreover, it secures ez publish, by cleaning properly all the XSS that you might got in if you have literal class=html activated (in my case, mandatory if I want to be able to have a ok looking RSS import). X+
http://www.sydesy.com
|
kavi kavi
|
Thursday 25 January 2007 7:12:12 am
Salut xavier !
merci pour tes compliments qui me touchent beaucoup. cela fait 4 mois que j'ai découvert eZPublish et PHP... Tu veux dire que ma solution est plus crédible que la tienne...?! ou c'est le contraire ? Je n'ai pas tout pigé... kavi
|
Xavier Dutoit
|
Thursday 25 January 2007 8:02:21 am
Salut, My solution is an extension that contains php code that does the work. It's more advanced than your solution (and likely to be faster too). I provides the ability to keep some tags (eg keep the bold and italic and links) and get rid of the others. It also allows to protect your site against attack if you let your users to publish html code in your content (ie if you have the literal tag with "html" class). X+
http://www.sydesy.com
|
Xavier Dutoit
|
Saturday 10 March 2007 2:52:43 am
This extension allows to shorten the xml result, even while keeping all (or a selection of) xml tags. http://projects.ez.no/xmlwash as an added bonus, it offers a bigger security, no matter your ez config, even while using the html class for the literal tag. X+
http://www.sydesy.com
|