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.

Searching Entries & Random Sort

January 27, 2009 10:51pm

Subscribe [3]
  • #1 / Jan 27, 2009 10:51pm

    Matt H.

    32 posts

    Hi,

    I’m trying to pull a random testimonial from my “Portfolio” weblog but not all the entries have the testimonial field filled in, so I have to be careful not to display an empty one. The problem that I’m having is that I only want to display one, but I want it to be a random one, yet the code below is not co-operating:

    {exp:weblog:entries weblog="portfolio" sort="random" search:testimonial_short="not IS_EMPTY" limit="1" dynamic="off"}

    The code above always displays the first entry that it finds with the search and it seems to just ignore the “random” sort part…

    Would anyone be able to point me in the right direction as to accomplishing the desired effect?

    Thanks in advance!

  • #2 / Jan 28, 2009 3:32am

    John Henry Donovan

    12339 posts

    Matt,

    I believe you are using an incorrect parameter in your tag. Replace the sort with an orderby

    {exp:weblog:entries weblog="portfolio" orderby="random" search:testimonial_short="not IS_EMPTY" limit="1" dynamic="off"}
  • #3 / Jan 28, 2009 2:40pm

    Matt H.

    32 posts

    Thanks John, that’s done it.
    For some reason or another I got confused with the whole orderby being a field and sort being the order but now I’ve changed it as per your suggestion and it’s working great 😊

  • #4 / Jan 28, 2009 3:15pm

    Ingmar

    29245 posts

    Glad to see you’Re all set 😊 Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases