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.

Channel Parameter Conditional Issue

March 06, 2012 11:03am

Subscribe [3]
  • #1 / Mar 06, 2012 11:03am

    Austin Siewert

    129 posts

    Hi,

    I’m getting odd results once I add a conditional statements to the channel parameter. When I remove the conditionals, the results are sorted correctly.

    Sorts oddly:

    {exp:channel:entries
      channel="prospects"
      category="{embed:cat_id}"
      disable="category_fields|member_data|pagination|trackbacks"
      dynamic="no"
      limit="75"
      {if "{freebie_2}" == "{current_time format="%Y"}"}orderby="prospects_pro_rating|prospects_college_rating"{/if}
      {if "{freebie_2}" != "{current_time format="%Y"}"}orderby="prospects_college_rating|prospects_pro_rating"{/if}
      require_entry="yes"
      sort="desc|desc"
     }


    Sorts correctly:

    {exp:channel:entries
      channel="prospects"
      category="{embed:cat_id}"
      disable="category_fields|member_data|pagination|trackbacks"
      dynamic="no"
      limit="75"
      orderby="prospects_pro_rating|prospects_college_rating"
      require_entry="yes"
      sort="desc|desc"
     }
  • #2 / Mar 06, 2012 11:49am

    zizther

    228 posts

    I have not tried placing conditionals to manage attributes in a channel entry call. It maybe this is not allowed.

    You could always use the conditional to control the whole channel entries call.

  • #3 / Mar 06, 2012 11:57am

    Austin Siewert

    129 posts

    I scrapped that idea and I’m passing a embedded variable to the orderby parameter and it’s working properly. Prolly more efficient too.

    {exp:channel:entries
      channel="prospects"
      category="{embed:cat_id}"
      disable="category_fields|member_data|pagination|trackbacks"
      dynamic="no"
      limit="75"
      orderby="{embed:filter}"
      require_entry="yes"
      sort="desc|desc"
     }
  • #4 / Mar 07, 2012 11:45am

    Shane Eckert

    7174 posts

    Hey Austin Siewert,

    Nice work. I like your current code block much better than the original.

    Have a great week.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases