I've also tried a number of other variations, e.g. matching on '0' not '[0]', change the condition_keyword value to just the metadata value, and changing the regex to any number of combinations, from matching on a non-empty string, matching on the exact value 'default', etc. Seems I've tried everything.
Post I've linked to above seems to indicate that asset metadata is being evaluated at a different time/place, but I know I've used Show_If's before based on metadata values.
What am I doing wrong? Or does anyone have an alternative way to do it? (besides customisations and/or paint layouts - I know these could be used but would have flow-on effects to site design complexity).
Not sure if begin/else works in parse files but if not, you could try and just comment that lineage area out with the conditional keywords, not as clean/pretty though:
When I do this, I usually use a select metadata field which has key/value pairs. If you are doing the same, then you might need to match the fields value, rather that its key.
e.g. If my metadata field's options are:
[0] Show lineage title
[1] Show page title
Then my "condition_keyword_match" would be "Show lineage title", not "[0]" or "0".
Also if it's a literal match, then you don't need the regex character class ("[0]"), the literal "0" character will do.
Thanks all for comments. Tried everything suggested above, still to no avail.
I've used metadata select fields successfully this way before, but in this case it's just a text field and it's not working. I'm really not sure why.
Bart, I like your idea with the %begin and %end keywords (and use that a fair bit elsewhere). It will work in this case but it won't in another of my cases, specifically the breadcrumbs. If I use the approach you've suggested I won't be able to turn off the breadcrumbs in a customisation if I need to down the road.
Really frustrating, I don't want to have to create a design customisation just so I can modify the page title, as that means I will have to re-create all the permutations of our children customisations (not to mention the oeverhead that we will need to apply customisations case-by-case, would prefer authors to do it themselves via metadata).
but it's still printing out the 'else' logic. Have triple-checked the field names and values in the metadata schema. Seems like the parse file is just not able to access the metadata values no matter what I do. Above code works fine in a Std Page embedded by a nested content in the design, but not directly in the parse file itself.
But it basically allows you do conditionally print content within those keyword structures based on if a keyword is empty or not.
Tim, I copy-pasted your code into a 5.1.12.0 system and it works as expected. I can't remember any bugs that would have caused this that were fixed, but maybe worth doing an upgrade.
There's another issue I've found - not sure whether I should raise it as new topic or keep it in this one. I'm using the conditional logic code similar to what you've supplied above:
So logic I'm expecting is the code in between the begin and end directives prints only if the metadata field LayoutOptions.BannerText has been filled. This is nested into the site design as a nested content area, this code is on a Std Page asset (hence the 'gobals_' to get to the asset itself).
Works perfectly *except* if I put this nested content into Safe Edit. When I do that, logged in users still see if correctly, but for Live view it's no longer doing the conditional - it prints out the inner contents - basically a heap of empty html. Once I put it back to Live again it starts working fine again.
Possibly also just a nuance of my version (v5.1.1)
I tested this and can confirm this is a bug in the latest version of Matrix as well. I've submitted a bug report and will hopefully be fixed in the next release.