Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Roll Template logic? Show A if B does not exist.

1437070387

Edited 1437071762
vÍnce
Pro
Sheet Author
I'm working on using images within a roll template's header. I want to show a "default" image unless an image is provided from a macro. Here's an example of code that's not working for me. Personal image from macro below works, but I can't get a "fall back" image to display...? &lt;rolltemplate class="sheet-rolltemplate-pf_generic"&gt; &lt;table&gt; &lt;tr&gt;&lt;td colspan="2" class="sheet-header"&gt; {{#header_image}} &lt;span class="sheet-header-image"&gt; {{#image}} {{header_image}} {{/image}} {{^image}} [Generic](<a href="http://i.imgur.com/ABCDEFG.png" rel="nofollow">http://i.imgur.com/ABCDEFG.png</a>) {{/image}} &lt;/span&gt; {{/header_image}} &lt;/td&gt;&lt;/tr&gt; {{#allprops() header_image image}} &lt;tr&gt;&lt;td colspan="2"&gt;**{{key}}:** &lt;span style="font-size:.90em;"&gt;{{value}}&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; {{/allprops() header_image image}} &lt;/table&gt; &lt;/rolltemplate&gt; macro example that can provide a personal image &{template:pf_generic}{{header_image=[Skill](<a href="http://i.imgur.com/1234567.png" rel="nofollow">http://i.imgur.com/1234567.png</a>)}} I'm sure it has to do with my confusion using {{^...}} Thanks in advance for any help. Cheers.
1437072532
Finderski
Pro
Sheet Author
Compendium Curator
Are you actually calling {{image}}? Because, if I remember correctly, when you use something like {{#image}} you are testing that image. So maybe change {{#image}} to {{#header}}? At least that's what I had to do on my roll template for bonuses: {{#bonuses}} &lt;tr&gt; &lt;td&gt;&nbsp;&nbsp; Bonuses:&lt;/td&gt; &lt;td class="sheet-roll"&gt;{{bonuses}}&lt;/td&gt; &lt;/tr&gt; {/bonuses}} That may not be it, but it's the only thing I can think of at the moment.
1437075634
vÍnce
Pro
Sheet Author
Thanks GV. I tried your suggestion by swapping {{#image}} with {{#header_image}} and I had the same issue with the default/generic image not displaying. ;-( Normally I use the same logic as your example, but I think my use case requires something different. I'm trying to display image A(the default/generic image) unless image B(personal image) exists so I thought I would need to "wrap" the property I'm testing within a different property because of the comparison needed. I could create a toggle in the sheet, but I'm trying to prevent that if I can.
1437079277
vÍnce
Pro
Sheet Author
[SOLVED] I was making it more complicated than it need to be. Go figure. No need to wrap anything and just keep the property name the same. Thanks for your help GV. &lt;rolltemplate class="sheet-rolltemplate-pf_generic"&gt; &lt;table&gt; &lt;tr&gt;&lt;td colspan="2" class="sheet-header"&gt; &lt;span class="sheet-header-image"&gt; {{#header_image}} {{header_image}} {{/header_image}} {{^header_image}} [Generic](<a href="http://i.imgur.com/H7zQfO6.png" rel="nofollow">http://i.imgur.com/H7zQfO6.png</a>) {{/header_image}} &lt;/span&gt; &lt;/td&gt;&lt;/tr&gt; {{#allprops() header_image}} &lt;tr&gt;&lt;td colspan="2"&gt;**{{key}}:** &lt;span style="font-size:.90em;"&gt;{{value}}&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; {{/allprops() header_image}} &lt;/table&gt; &lt;/rolltemplate&gt;
1437079823
Finderski
Pro
Sheet Author
Compendium Curator
[*thumbs up]
1437118510
Kryx
Pro
Sheet Author
API Scripter
I'm still surprised that the first didn't work... Glad you got it figured out.
1437132790
Lithl
Pro
Sheet Author
API Scripter
The first version should also work, but in order to see the custom image, you'd have to define both header_image and image. (And in order to see the default/generic image, you'd have to define header_image without defining image.) That's obviously not what was intended, though.
1437151498
vÍnce
Pro
Sheet Author
Brian said: The first version should also work, but in order to see the custom image, you'd have to define both header_image and image. (And in order to see the default/generic image, you'd have to define header_image without defining image.) That's obviously not what was intended, though. I see. Thanks for the calrification Brian. Much appreciated.