This is one that has been asked before but none of the solutions I've seen seem to work.
The problem: you have a data source, say JSON, and make an asset list of the data source records.
You can put a Default Format on the list that will set the display of the individual records - you can use keywords,including field value keywords, etc.
Well and good. Works fine, but type formats in asset listing can't contain conditional logic, either conditional keywords or directly code conditions.
As I commented in a previous post, this just seems an oversight - no good reason whatsoever it has not been implemented. And you need it! If there are empty fields in the JSON you want to ignore any associated display.
The solution in other cases (where you are listing standard pages or news items for example) is to use a paint layout (which can contain conditions).
To do this , you put a keyword of the form %asset_contents_paint_xxxx% where xxxx is the asset id of a paint layout e.g. %asset_contents_paint_1546946% in the default format of the asset listing.
For data source records, however, this does not work. Nothing is displayed. Is this because data source records are "ghost assets" or some nonsense as another poster has claimed?
It is very frustrating trying to get this to work. As some may have guessed, I'm a developer used to writing sql and formatting the results in a scripting language, thus doing in 5 minutes what I've spent days figuring out how do in Matrix.
I sense (and often share) your frustration. Often the issue with developing with a CMS (and this is not specific to just Matrix) is wrestling with the system to get it to do what you want. If you've come directly from a SQL+sever-side background you probably had very powerful access to the underlying data, may have a very strong if-else coding paradigm, and so may need to learn alternative approaches (I commiserate this will feel like pulling teeth at first, and maybe forever, but if this is the CMS you're working with need to learn to work with it). A post I wrote some time ago that may get you some of what you want:
I should add that in later versions (my post was targeting v4.12) there has been a lot of functionality added that may be useful, specifically around 'replace_keywords', which I now use extensively to avoid design customisations and paint layouts (both of which I avoid like the plague - possibly just old habits). For example:
<!-- display a callout if there is intro text, otherwise nothing -->
Something else that has improved a lot in later Matrix versions is applicability of keywords in more locations. E.g. in some earlier versions the methods I've described above did not work in certain bodycopies but did in others (e.g. not working in an Asset Listing Page Contents but works in the same listings Type Formats). I noticed this as a particular issue with Data Record Sets, so that's something else to send you barking mad. Again, much improved in later versions.
Most browsers can figure this out and just ignore the erroneous stuff in the closing element. Tested in Matrix v5.1.
Wonder if this would be a good enhancement request. Surely it wouldn't be that hard to strip out the extra stuff after the tag name. It would literally be everything after the first space inclusive.
This is one that has been asked before but none of the solutions I've seen seem to work.
The problem: you have a data source, say JSON, and make an asset list of the data source records.
You can put a Default Format on the list that will set the display of the individual records - you can use keywords,including field value keywords, etc.
Well and good. Works fine, but type formats in asset listing can't contain conditional logic, either conditional keywords or directly code conditions.
As I commented in a previous post, this just seems an oversight - no good reason whatsoever it has not been implemented. And you need it! If there are empty fields in the JSON you want to ignore any associated display.
Conditional logic in type formats should also work, probably a bug that has been fixed since your version, I use them all the time in asset listing type formats.