Tuesday, July 30, 2019

Meeting Visualizer Troubles (can you hear me NOW)

Background: Government is filled with meetings, we have meetings to talk about upcoming meetings and meetings we just had sometimes we even have meetings to discuss how to avoid other meetings. So I knew that one of my content types was going to have to be "Meeting" or in my case I was going to call it "Event" so it sounded more generic.

In my world a "Event" has certain "must-have" elements...

  • Title [Textbox, also becomes Content Item Name]
  • Description [Multi-line plain Textbox]
  • Begin Date/Time [Date/Time]
  • Is it all day? [Radio button yes/no]
Then it has additional optional information...
  • End Date/Time [Date/Time]
  • Physical Locations (zero or more reference objects of type PhysicalLocation described below)
    • Required elements
      • Address Title [Textbox, also becomes Content Item Name]
      • Street Address1 [Single Line TextBox]
      • City [Single Line TextBox]
      • State [Single Line TextBox]
      • Zip Code [Single Line TextBox]
    • Optional Elements
      • Street Address2 [Single Line TextBox]
      • Rollup Image [Asset]
  • Virtual Location Information [Multi-line plain textbox]
  • More Information Type (this determines where the title links to in the "list" visualizer)
    • Event Details [HTML]
    • Webpage [URL]
    • Document [Asset]
    • None
  • Agenda [Asset]
  • Minutes [Asset]
  • Event Documents [Asset(s)]
This seems like a good starting place and I'll be adding onto it as I go. Now onto my issue.

Issue: Often times there are multiple committees and/or subcommittees as well as we need to display these in a way that my users are accustomed to I need to be able to seperate the "Upcoming" meetings from the "Previous" meetings.

Solution(s):

For the "committee" and "subcommittee" portion I'm going to leverage the "tag" portion on the content item.  Users should be able to start entering the committee and subcommittee name into the tag box and after the first entry of a given committee it will auto-prompt them.  Now this is a little prone to user error, but it gives great flexibility for the names to be added to and deleted over time. The I can just throw visualizers on the page and use the default "filter" to limit which committee is show on a given page.  This should accomplish the need to separate out committee schedules in a way that's fairly easy for the users to manage and me to control.

That was the easy part, the other part is much more complex since the visualizer ONLY allows you to filter by "TAG". Even the advanced URL filtering has trouble doing logical assessments and is more adapt at doing things like "beginswith" or "endswith" type evaluation.  Here I need a "time" evaluation to limit what is showed.

Having nothing at hand I had to get creative and the answer was in creating TWO visualizers, one for "future" events and one for "previous" events. This wasn't ideal but it would work if i could get the visualizer itself to determine which results to show vs not show.  The problem was NOTHING in the documentation for date filters showed a way to compare a datefield to "NOW" or "TODAY". It existed in the Shopify version of liquid but not in the EVOQ version. So after MUCH searching and trial and error I found a couple crumbs that when combined showed me an UNDOCUMENTED ENUM.

By using the code below I'm able to get the current date/time in a formatted manner and assign it to a variable that I CAN then use in an IF statement.
{% assign xNow = 'now' | date: "MM/dd/yyyy" %}
You can add hh:mm:ss to formatting filter to get the time as well, but in my situation I only needed the date.

So now my if statement looks like this to get me my "Upcoming" events.
{% assign xNow = 'now' | date: "MM/dd/yyyy" %}
{% assign xbeginDate = beginDateTime | date: "MM/dd/yyyy" %}
{% if xbeginDate >= xNow %}
...
...
..
{% endif %}
And I'll be darn it works!  Hopefully this saves you some time looking through tones of other sites.

No comments: