sort_by rand()

Author Message

Caroline Condamin

Tuesday 13 January 2009 7:51:17 am

Hi,

In a template, I have a list retrieved with this code:

 def $my_list = fetch( content, list, hash( parent_node_id, 2810, 
							class_filter_type, "include",
							class_filter_array, array(141)))

I want to sort this list by a random way.

I've tried:

sort_by , array('rand()', true()) 

, but it does not work.

Is there somebody who has a solution?

Thanks!!

Ciji

Christophe Condomines

Tuesday 13 January 2009 11:56:06 am

Check this:

http://ez.no/developer/contribs/template_plugins/shuffle_4_0

Microblau SL
http://www.microblau.net

Caroline Condamin

Wednesday 14 January 2009 8:36:30 am

Great,

Thanks! This solution solves the first part of my problem.

The second one is that I need to generate a new random array each time I refresh my page... but now I have a problem of cache!
Somebody has already posted a topic here :

http://ez.no/developer/forum/developer/shuffle_and_cache_please_help

I'm gonna follow this discussion.

Thanks a lot for your help Christophe.

Ciji.

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 18 2025 16:15:39
Script start
Timing: Jan 18 2025 16:15:39
Module start 'layout'
Timing: Jan 18 2025 16:15:39
Module start 'content'
Timing: Jan 18 2025 16:15:39
Module end 'content'
Timing: Jan 18 2025 16:15:39
Script end

Main resources:

Total runtime0.0160 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.0052 587.7891152.6094
Module start 'layout' 0.00530.0035 740.398439.3984
Module start 'content' 0.00870.0050 779.796989.4141
Module end 'content' 0.01370.0023 869.210930.3047
Script end 0.0160  899.5156 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002817.1477140.0002
Check MTime0.00127.2332140.0001
Mysql Total
Database connection0.00074.461110.0007
Mysqli_queries0.002314.487130.0008
Looping result0.00000.150010.0000
Template Total0.001911.910.0019
Template load0.00105.957110.0010
Template processing0.00105.957110.0010
Override
Cache load0.00074.293210.0007
General
dbfile0.00021.533180.0000
String conversion0.00000.066840.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.0002 secs