Forum for discussing general topics related to Couch.
6 posts Page 1 of 1
Hello, i'm trying couch now, before i was using wordpress. but for basic shared hosting wordpress is heavy. for basic to medium complex site couchcms is perfect. i think we can build more and more complex sites using this. so I appreciate each and everyone behind this masterpiece.

Now I tried to fetch folders in random order. but it's not working.
I used orderby='random' for <cms:folders masterpage="blog.php" orderby='random' order='desc' paginate='1' hierarchical='1' limit='4'>

pls help me to achive this...
Hi,

Thanks for your kind words :)

As for the issue you mentioned -
I am sorry but the only values the 'orderby' param of <cms:folders> accepts are 'name', 'title', 'id', 'count' and 'weight'.
Thank you :) In case anyone goes for it, I'll post two ideas. A custom SQL query fetching folders in random order (seeded query for valid pagination) could be used in <cms:query>. Another way is to fetch randomly the associated pages of extended-folders template and then fetch a folder for each selected page. In both cases I do not see how hierarchy could be maintained (hierarchical='1' :roll: ). ¯\_(ツ)_/¯
@trendoman
In both cases I do not see how hierarchy could be maintained

I agree. Moreover, the use of paginate='1' will complicate the issue further - how would you prevent folders that have already appeared previously from showing up again as the pagination progresses? The entire recordset would need to be placed in session to pull this off.
t
@kk, in the first case, with a custom query, a constant (initially random) seed value for the RAND() function is passed via query string or session e.g. SELECT * FROM couch_folders ORDER BY RAND(333) LIMIT 0, 3;. Pulling or storing the entire recordset is thus not required. I guess, Couch already has this for paginated 'random' pages, hence the second idea has this covered. Was there something else missing here?
KK wrote: I agree. Moreover, the use of paginate='1' will complicate the issue further - how would you prevent folders that have already appeared previously from showing up again as the pagination progresses? The entire recordset would need to be placed in session to pull this off.
t
Thank you @KK and @trendoman

I will try these two solutions.
6 posts Page 1 of 1
cron