Display icon in description IF field value is "yes"
I was wondering if anybody has configured their viewer description to display an icon as a result of an if/then statement?
I would like to display user-type icons for trail segments (hike, bike, etc) if the value for associated the user-type field is "yes". I find that simply including these fields in the results list is cumbersome as the fields are irrelevant if that user-type does not apply to the trail segment.
ie:
if <user-type-hike> == "yes":
display icon <type-hike>
else:
pass
if <user-type-mntbike> == "yes":
display icon <type-mntbike>
else:
pass
These icons, where relevant, would then sit side-by-side in the description
Any suggestions or previous success with similar process?
Thanks!
0
-
Suzanne
Did you ever get this to work?
Thanks0 -
I wish, but no. I've since moved on but would still love to make this happen if anybody has a way! 0 -
You can add custom script to your viewer but not through the Rest Manager. I think that an easier path for you is to hide the icons with CSS, I've done something similiar in the past.
Here's the basic process, using the original post as an example:
1) write the feature description to include both icons
2) write custom css to hide a class, the name of which includes your desired value in the data eg.icon-mtnbike-no { display:none; }3) add that class to your icons, but replace the text from your data (in this case "no") with the token for that field eg.<img class="icon-mntbike-{usr-type-mtnbike}" src="http://sub.domain.loc/some.img">
Thus you will hide the icon when the data's value is "no". With further effort, you can do the opposite and only show the icon when the value is "yes" (or whatever value you like) by placing the data token apart from the rest of your custom class and writing an additional rule, so your html looks likeclass="icon-mtnbike {token}"and your css looks like.icon-mtnbike { display:none; } .icon-mtnbike.yes { display:block; }0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
3 Kommentare