Sunday 23 June 2019

carto - CartoDB infowindows - only show title if data exists?


I have a data set in which not all tuples have info for all columns.


I want to show those columns in the infowindow, but if the data value is inconsequential (doesn't exist, is zero in a field where zero equates to doesn't exist), I don't want the title of the field shown - absence should be sufficient to show the user that the data isn't there.


How would I do that?



Answer



The easiest way is to use the mustache templates. In the custom HTML infowindow field (or hovers), you can put the following around text you want to conditionally appear:


{{#col_name}}

{{col_name}}


{{/col_name}}
{{^col_name}}

No information


{{/col_name}}

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...