ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Random order doesn't seem to work when selecting from multiple channels

July 01, 2011 6:23am

Subscribe [5]
  • #1 / Jul 01, 2011 6:23am

    ip

    80 posts

    {exp:channel:entries channel="channel1|chanel2|chanel3" search:featured="Yes" limit="1" orderby="random"}

    this returns the same entry every time, is it possible to order by random from multiple channels?

  • #2 / Jul 01, 2011 6:38am

    ip

    80 posts

    It does work, if I clear the cache between page requests!

    There must be a better solution?

  • #3 / Jul 01, 2011 1:57pm

    Sue Crocker

    26054 posts

    Hi, ip. If you’re using caching, that would make sense why it doesn’t work until you clear the cache.

    Untested, but you could have the exp:channel:entries loop in a template that isn’t cached. Give it a try. Or cache the bits and pieces inside the template by having them be cached embeds.

  • #4 / Jul 01, 2011 2:35pm

    ip

    80 posts

    Hi,

    ‘Enable caching’ is set to ‘no’ for the template.

    I’ve just limited the tag to a single channel and it still seems to require the cache to be cleared, I don’t think it’s caching anywhere else as it works everytime I clear ee’s cache.

    For the clear caching to work it has to be the ‘All caches’ option.

  • #5 / Jul 06, 2011 6:03pm

    ip

    80 posts

    To get this working I’ve had to retreive more than one entry and then just display the first, but I’d really like to know why it isn’t working correctly.
    ie:

    {exp:channel:entries channel="news" search:featured="Yes" orderby="random"}
    {if count==1}
  • #6 / Jul 07, 2011 4:19pm

    Brandon Jones

    5500 posts

    Hi ip,

    As far as I can tell, that’s normal behavior if you’re using template caching. Have you tried using tag caching instead? That might be a good middle ground between caching and somewhat apparent randomness.

  • #7 / Jul 21, 2011 9:56am

    ip

    80 posts

    Hi, apologies for the slow reply.

    I’m not using template caching, ‘Enable caching’ is set to ‘no’ for the template.

    Is it the case that the fetch is done first and then the returned results are randomised, in which case limiting to 1 would always return the same result? I was assuming that the randomisation would be left to the sql call.

    thanks,
    ip

  • #8 / Jul 25, 2011 12:48pm

    Kevin Smith

    4784 posts

    Hi ip,

    If the behavior you expect to see only happens when you clear the cache, then there’s some kind of caching being employed here. Have you taken a look at query caching? Do you have that enabled?

  • #9 / Jul 25, 2011 1:05pm

    ip

    80 posts

    hi

    ‘Enable SQL Query Caching’ is disabled.

    thanks,
    ip

  • #10 / Jul 26, 2011 4:36pm

    Brandon Jones

    5500 posts

    Hi ip,

    After you clear all caches and then view the template again, what folders are created under system/expressionengine/cache again?

  • #11 / Jul 27, 2011 1:41pm

    ip

    80 posts

    ee_version
    sql_cache

    thanks,

    ip

  • #12 / Jul 27, 2011 3:31pm

    Sue Crocker

    26054 posts

    Hi, ip.

    sql_cache means you have SQL Query caching turned on. Have you tried turning that off? You can find it via Admin > System Administration > Database Settings.

  • #13 / Jul 27, 2011 3:42pm

    ip

    80 posts

    ‘Enable SQL Query Caching’ really is set to off, I wasn’t lying!

    ‘Enable Database Debugging’ is set to on, would that have any effect?

    thanks,

    ip

  • #14 / Jul 27, 2011 4:17pm

    Brandon Jones

    5500 posts

    ip, in your database.php file, what is set for

    $db['default']['cache_on']

    ?

  • #15 / Jul 28, 2011 6:48am

    ip

    80 posts

    That’s set to false.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases