CSV Data Source Record Set Keyword as a Modifier Parameter

(Lewis) #1

Any idea why the following doesn’t work? %begin_globals_get_town^eq:Medway% works but substituting {ds__town} doesn’t. %ds__town% returns ok


(John gill) #2

because %globals_ keywords are processed later than %ds__ (and %asset_) keywords, so by the time the conditional keyword is actually handled the meaning of %ds__ is lost.

The first thing I’d try is to flip the keywords and see if



I think this keyword construction should throw a warning when saved, this is the most common keyword misunderstanding I see by a wide margin.

Anytime you’re using an early processed keyword as a replacement keyword in a late processed keyword you’re liable to get nothing at best, and misleading behaviour at worst (things that look like they work, but they’re working for a different reason than you think which blows up in your face down the road).

There are plenty of cases where %late:{early}% seems to work, but as far as I can tell in those cases you could more accurately construct them in a %late:{late}% fashion.



might work sometimes, but in those cases it would be less ambiguous to write it as


As far as I know, the latter keyword is a more accurate representation of what Matrix actually does when it processes it.

(Usual disclaimer that I’m wrong about heaps of things every day, and I might be missing something, but if anyone has an example of a %late:{early}% keyword that both works and isn’t better expressed as %late:{late}% then I’m very keen to see it)

(Lewis) #3

Hi @JohnGill. I’ve tried flippiing it around as you suggested but it doesn’t work.

Essentially I’m trying to filter a list of community groups by town. I know this is possible with a straight Asset Listing but I’m led to believe (from the manual) that this is only possible when the records are grouped into folders - something that it isn’t really practical to do when you’ve uploaded a CSV file, especially for the content writer with less technical knowledge.

Any ideas? Do you have a link to Squiz’s documentation where processing order is mentioned? I’m sure I’ve seen it but can’t find it now.

(John gill) #4

I just tried a sample to check, and at least for a test case it can work.

Using a CSV Data Source that contains


and an Asset Listing Page that contains both versions of the conditional block

    <li>%ds__name%,%ds__category%        <b>early{late}</b> </li>

    <li>%ds__name%,%ds__category%        <u>late{early}</u> </li> 

then I request the page with ?category=meat and I see

  • escargot,meat early{late}
  • goat,meat early{late}

(testing on

Obviously there could be any number of other factors going on, but it should be possible to compare a CSV data source value to a %globals_get param if you put the data source value first.

The only reference for execution order I know of is https://matrix.squiz.net/manuals/concepts/chapters/server-side-javascript#processing-order . It doesn’t refer to the late{early} issue directly, but you can see how it would happen.

(Lewis) #5

Hi @JohnGill. Thanks again for taking a look at this. The {late} one works for me and the {early} one doesn’t. The only difference I can see between this code and your earlier code is that you’ve closed out the %end’s with %end_ds% etc instead of %end_globals% (the earlier code didn’t work).

It’s working now anyone so thanks for taking the time to help! :blush: