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.

Problems with Switch statement when using Orderby and Sort

January 08, 2008 2:20pm

Subscribe [1]
  • #1 / Jan 08, 2008 2:20pm

    mcneasep

    21 posts

    So I have this page located Here. It’s supposed to pull in a list of courses with the “class type” as “Guest Series” which is set in the blog entry itself.  It’s then supposed to order them by expiration date and then sort ascending.  The problem is, the switch statement is being done before it pulls out the unnecessary entries (ones that aren’t guest series), so we end up with rows the same color and not the desired zebra effect. 

    It works fine if I don’t use the orderby=“expiration_date” sort=“asc”.  The code is below.

    NOTE: I think the only reason the “Past Sessions” is alternating correctly is because there aren’t enough past classes yet to throw off the order.

    
    									
  • #2 / Jan 08, 2008 2:34pm

    Lisa Wess

    20502 posts

    Yes, the conditional will simply hide that information, switch will still include it in its switching.  You could use the search: parameter to limit by that custom field, instead, which would work.

  • #3 / Jan 08, 2008 2:36pm

    mcneasep

    21 posts

    Any ideas as to how I’d go about setting that up?  Or why the switch still includes things that should be excluded?

  • #4 / Jan 08, 2008 2:40pm

    Lisa Wess

    20502 posts

    Well, just to clarify - sort and orderby are not the problem.  The problem is the conditional.  Here is how it works:

    Parameters - limit and change the output immediately
    Conditionals - Hide or change the output after the fact

    The problem here is that your conditionals are simply hiding information - it’s still being processed, so your switch is still going through that data. 

    What I think you want is to limit by custom field, which means you want the search:// parameter =)

  • #5 / Jan 08, 2008 2:48pm

    mcneasep

    21 posts

    Wow, that worked perfectly.  And to think I didn’t even know about search before.  Very nice.  Thanks for helping me out again!

  • #6 / Jan 08, 2008 2:57pm

    Lisa Wess

    20502 posts

    search: was introduced in 1.6.1, so it’s fairly new.  Pretty neat, eh? =)  Glad you got it working!

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

ExpressionEngine News!

#eecms, #events, #releases