| Fátima Chapri
                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Sunday 11 January 2009 3:51:12 pm 
                                                                
                                                                 I was searching for a ez random function that could fetch random articles of a folder but didn't find. So I tried the above solution and it worked. I'm just wondering if this is the best solution. Wouldn't it be better to create a function with php code? 
{ def $children = array()
  $children_count = ''
  $rand_number = ''
  $last_rand_number = ''
  $rand_list = array()
  $counter = 0
  $counter_end = 4
  $object = '' }
{ set $children = fetch( 'content', 'tree', hash( 'parent_node_id', $node.node_id,
                        'class_filter_type', 'include',
                        'class_filter_array', array( 'article' )))
  $children_count = fetch( 'content', 'tree_count', hash( 'parent_node_id', $node.node_id,
                         'class_filter_type', 'include',
                         'class_filter_array', array( 'article' ))) }
{ while ne($counter, $counter_end) }
   { set $rand_number = rand(0, $children_count|sub(1)) }
   {if ne($last_rand_number,$rand_number)}
      {set $rand_list = $rand_list|append($children[$rand_number])
			      $counter = inc($counter)
			      $last_rand_number = $rand_number }
   {/if}
{/while}
{foreach $rand_list as $object }
   <h4><a href={$object.url_alias|ezurl}>{$object.data_map.title.content|wash}</a></h4>
{/foreach}
{undef}
 |