1

I'm using DevDemon's Channel Videos to include videos into my entry. I'd like to output only up to 2 videos, randomly selected from my list. Unfortunately the orderby="random" option isn't available. Is there another way to easily accomplish this? Thanks for any help.

3 Answers 3

2

If you were to output your Channel Video tag loop into a Stash list, using {stash:set_list}, then you could pull a random subset out via {stash:get_list orderby="random" limit="2"}.

Here are links, for more info: Stash Set List and Stash Get List. There also are lots of Stash list examples here on the EE Stack Exchange.

2

If you can get the total number of returned results (say, 10 videos) you could probably use one of the two add-ons below to return a random number in that range for a {if count == "3"} conditional?

http://devot-ee.com/add-ons/random-between

or

http://devot-ee.com/add-ons/low-random

Just thinking outside the box with no experience with Channel Videos.

1
  • 3
    Lottor-ee works super well in this scenario too! devot-ee.com/add-ons/entry-lottoree Lots of favorites as well! Whenever I'm looking for a new add-on I always look to see how many favorites it has :) Commented Nov 16, 2013 at 2:44
0

Thanks all for your answers. In the end Stash looks like the most direct solution. Though it's nice to know those other random generators exist--I was close to trying out low_random just for the heck of it since it looks so useful.

Here's my stash code btw

        {exp:stash:set_list name="videos" parse_tags="yes"}
    {exp:channel_videos:videos entry_id="{entry_id}" embed_width="300" embed_height="169"}
       {stash:embed_code}{video:embed_code}{/stash:embed_code}
            {/exp:channel_videos:videos}
        {/exp:stash:set_list}

        {exp:stash:get_list name="videos" orderby="random" limit="2"}
           {embed_code}
        {/exp:stash:get_list}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.