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.

Conditional status for exp:entries

January 07, 2011 11:22pm

Subscribe [3]
  • #1 / Jan 07, 2011 11:22pm

    Moe 2.0

    24 posts

    Hi,

    I’m trying to retrieve both open and Draft entries for certain user groups by doing:

    {exp:channel:entries channel="news" limit="10" paginate="top" dynamic_parameters="category" {if member_group == '1' OR member_group == '6' OR member_group == '7'} status="open|Draft"{/if}}

    The loop is returning Draft entries for all user groups.  Category is set to dynamic because it is being passed in from a form and is working without issue.

    I’ve tried member_group and group_id, but no luck.

    EE 2.1.3 - Build 20101220

  • #2 / Jan 10, 2011 1:31am

    John Henry Donovan

    12339 posts

    Moe 2.0,

    Using a conditional for a parameter would be incorrect.

    Try it like this

    Make sure to close the entries tag in each condition

    {if member_group == '1' OR member_group == '6' OR member_group == '7'}
    
    {exp:channel:entries channel="news" limit="10" paginate="top" dynamic_parameters="category" status="open|Draft"}
    {/exp:channel:entries}
    
    {if:else}
    
    {exp:channel:entries channel="news" limit="10" paginate="top" dynamic_parameters="category"}
    {/exp:channel:entries}
    
    {/if}
  • #3 / Jan 17, 2011 10:13am

    Moe 2.0

    24 posts

    Thanks John.  That worked.

    I also tried using the session variables plugin without any luck.

    It would be much easier if EE could parse a variable for the status parameter.  I’m going to submit that as a feature request and see what happens.

  • #4 / Jan 17, 2011 4:14pm

    Ingmar

    29245 posts

    Very good. Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases