Do you have some feature in mind that you'd love to see in Couch? Let us know.
4 posts Page 1 of 1
Would it be possible for us to have a tag that generates a random number? - i.e.:

Code: Select all
<cms:random '10' />


While I know this can be easily accomplished using php directly, I thought it would be nice to have a php-less alternative in Couch. :-)

This could be useful in many situations - i.e.; randomised captcha questions, randomised pictures, etc.
Yes, it would be a nice feature)
Anyway, Couch gives a great possibility to create arrays, so I often use array_unique (for displaying article's or gallery's tags for example), array_rand etc., it's really not so difficult to implement.
But it's a good idea I think to make an addon with a lot of array operations like
Code: Select all
<cms:arr_operation "<cms:pages><cms:show my_variable /></cms:pages>" />

Maybe in later versions we'll see it)
Here I've made a simple solution for tags and random images using slightly different approaches: http://psycheworld.ru/couch-sample/gallery.php.

The sample gallery is powered by jQuery-free List.js that is ideal for small galleries (< 100pcs) that need live search, custom sort and pagination, and also tags system. The script may be used for large galleries accompanied by LazyLoad script, anyway it's the fastest solution I've ever seen for nice galleries. If more power and effect control are needed I use MixItUp, nice script too, but jQuery-based.

Have attached the gallery template (it's based on the @cheesypoof's free theme).

Attachments

I have a pretty good snippet for randomizing numbers. Using the <cms:php> tag and <cms:set> you can either randomize set numbers (say 1-10) or use a variable (say number of cloned pages):


This would set a random number between 1 and however many published cloned pages I have:
Code: Select all
<cms:set adcount=k_total_records />
<cms:set randad = "<cms:php>echo (rand(1,\"<cms:show adcount />\"));</cms:php>" />
Total records: <cms:show adcount /><br>
This ad: <cms:show randad />


This one sets a specific set of numbers:
Code: Select all
<cms:set rand_img="blog_image<cms:php>echo (rand(1,4));</cms:php>" 'global' />
<img src='<cms:get rand_img />'



KK helped me with this code a while back but I when i searched this post, I never found it again. So I thought I'd make it available for anyone who may need it. (which of course includes the future me :mrgreen: )
Hopefully this helps!
COUCH IS AWESOME AND THIS COMMUNITY IS THE BEST EVER BECAUSE OF THE AMAZING SUPPORT STAFF!!
4 posts Page 1 of 1
cron