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.

Using "orderby" parameter with two fields

August 25, 2010 6:48pm

Subscribe [5]
  • #16 / Sep 17, 2010 5:05pm

    Stephen T

    127 posts

    Hi Robin,

    Sorry I didn’t get back to you right away on this - I was sick for a couple of days.  Thanks so much for the detailed code - color me impressed.  I’ve got it working in it’s most basic form and it’s sorting correctly by date first and by school name second.  You can check it out here: http://bit.ly/d1XzLu.

    I do have a couple of questions:

    1) What’s the reason you have two query fields set up for the date field - one called dday and one called sday?

    2) Some of the meets are only one day and some last longer than one day.  So there is a field called invitational_meet_end_date that is only entered if the meet lasts longer than one day.  Then I choose how to display the date based on a conditional that checks if that field exists.  This doesn’t seem to be working for the query though - it spits out December 31, 1969 for the invitational_meet_end_date field on every entry.  Is there a way around this?  You can see what it’s doing on the sample link I gave above.

    3) You mention a plugin to get the fields in the proper format.  Did you have one in mind?

    Thanks again for all your help.

  • #17 / Sep 20, 2010 10:00pm

    Robin Sowell

    13255 posts

    Hrm- The 1969 date is what you get when it can’t format to a proper date (basically).  Try showing it unformatted- I somewhat suspect it’s in as a ‘0’- if it is, just change your conditional to use that instead.

    For the formatting- since you’re pulling the data straight from the db, the fields don’t have the formatting setting applied (i.e. xhtml typically).  But- you can do this as needed for each field using the XHTML Typography Plugin.

    And- for the first question- you really only need the sday (my shorthand for ‘sort date’).  The dday (display day shorthand) was for comparison.  I wanted a quick comparison with the formatted date- which is run through some localization tweakage.  Which is a long way of saying- your sort date is in gmt time.  However, if your users are not on gmt time (highly likely if you allow them to localize) you can end up with dates that appear to be hours off- which may trip up the sort cut off.  Hope that makes sense.

    I meant to go take a look at the localization class and figure a way of ‘offsetting’ the sort date based on the users localization setting.  So if they’re 3 hours ahead of gmt- add 3 hours to the sort date before using it in the query.  I just hadn’t poked it yet.  I’m betting you do allow localization and all dates aren’t forced to gmt- correct?

  • #18 / Oct 05, 2010 4:33pm

    Stephen T

    127 posts

    Hi Robin,

    I finally had a chance to dig into this again after getting pulled onto another big project for a couple of weeks.  I think I’ve got it working properly now - I’m pulling in all the fields and they are being sorted by school name first, then by the event date.

    You’re correct, all of the dates are not forced to GMT, but I must admit that I’m a little lost when it comes to the localization issues for the time.  However, right now all of my users in Texas, so I don’t haven’t had to deal with any time zone issues, but those might pop up somewhere in the future.  If you have a chance to take a look at the localization class to figure out a way to offsetting the sort date based on the users location, that would be wonderful.

    You’ve been a great help.  Thanks so much for the time you’ve spent on this.

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

ExpressionEngine News!

#eecms, #events, #releases