Blog

Squiz Matrix and Using Complex Keyword Modifiers

Wed, Oct. 5, 2011

Today I was working on creating a .ics file for Pacific Union College and I ran into a problem. Because I wasn't using an asset listing (using a Rolling Calendar Page) I wasn't able to use conditional keywords in order to change some of my output.

The problem was, iCal files are picky. They have to validate just like an RSS feed would. The DTSTART property must be printed differently if it doesn't contain a time. I wanted to check the results of a keyword to see if it didn't contain a time, which shows up as --:--:--. I also needed it to write some extra text if it didn't contain time. Here is what I came up with:

%asset_attribute_start_date^contains:--^replace:3:;VALUE=DATE^replace:0:%

Breaking It Down

Here is how this keyword works. It will be printing the date/time in two different ways. Assets that have a time will print like 20110122T111500 while another might just print 20110122, which is without a time. If I don't have a time, I need to also add ;VALUE=DATE, this tells the file it is only a date.

The keyword modifier looks at the result of the asset_attribute_start_date keyword and checks to see if it contains any --, if it does, it will return the number of times it find that, in my case, 3. So, I want to replace that number 3 with ;VALUE=DATE but if it returns 0 (meaning it found nothing) then we just want to replace it with a blank string.

It seems complicated but it actually is really logical and works really well. Very powerful stuff!

I found a bug in Matrix that prevents keyword modifiers from being used on event keywords such as %event_start_time_12h%, so if that had worked there would have been more than one way to accomplish this.

Nicholas Hubbard
Owner

Comments

Paul Wojciechowski
Oct 6, 2011
Great!
Ash
Sep 3, 2012
I'm a little lost at the ";VALUE=DATE" part. Where does that value come from (metadata etc) and what does the ";" do?
Curious
May 14, 2013
How does this work if the original date/time contain a 3 or a zero? How does the replace modifier know which one to operate on?

Add Comment