Thursday 13 November 2003 11:34:10 am
Hi Glenn, I use a long winded solution because I don't want to touch the kernel. (The easiest solution is a "random sort" parameter in the fetch-template function, I mentioned this some weeks ago in a post, but nobody answered ...). My solution: You (hopefully) know in which folder your images are placed. Now you need a random number. To get the random number, you have to create an own template operator (look at http://ez.no/developer/ez_publish_3/documentation/development/kernel/custom_template_operators) for further details. Define an operator like "random_number" in the modify-method of your own template operator class do something like:
function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters )
{
switch ( $operatorName )
{
case "random_number":
{
$operatorValue = rand($namedParameters['start'],$namedParameters['end']-1 );
}
break;
} } (...) in you .tpl do something like:
{let image_folder_id=422
image_list_count=fetch( content, list_count, hash( parent_node_id, $image_folder_id ) )
random_image=0 }
{set random_image=$image_list_count|random_number(0,$image_list_count)}
{section loop=fetch(content,list,hash(parent_node_id,$image_folder_id,
class_filter_type, "include",
class_filter_array, array(5),
offset, $random_image,
limit, 1 )) }
.... image output ....
{/section} {/let} Hope that helps.
Bye, Emil.
Best wishes,
Georg.
--
http://www.schicksal.com Horoskop website which uses eZ Publish since 2004
|