0

I have a channel entry that I want to display limited results and also only show results with a certain conditional applied to it.

Right now I am opening the channel entry and setting a limit inside of the channel opener, and then inside of that limit the conditional runs. So when the channel entries are displayed the channel limit runs first then it filters the conditional, and there are less than the limit of entries showing because not all of the entries met the conditional. Here is my example:

 {exp:channel:entries
  channel="staff"
  orderby="random"
  limit="12"
 }

  {if staff_photo !=""}
   12 photos
  {/if}


{/exp:channel:entries}

In this example, there are some entries in my channel that do not have a photo. I only want to display entries that have a photo first, then of those entries with a photo, I only want to show 12. Is there a better order of operations or way to structure this conditional? I tried using an embed to first call in the channel then filter the limit with the embed but was not having much luck with that. Any insight is greatly appreciated.

0

You can use the limitand the search:field parameters together.

{exp:channel:entries
    channel="staff"
    orderby="random"
    limit="12"
    search:staff_photo="not IS_EMPTY"
}
    [...]
{/exp:channel:entries}

There's a setting for empty fields.

  • This works perfectly! Thanks for sharing those docs. I guess I didn't dig deep enough. Thanks for your help! – j_lemon Aug 17 '16 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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