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

Custom template help - adding myproperty

In my custom character sheet, I've been using Jakob's Better Default Template. I want to add one pre-defined property, similar to Title, Subtitle, and Desc(ription). (Actually, just like 'desc' but have one left-justified and one centered.) According to the wiki, all I need to do is add a div with {{myproperty}} in double curly brackets, and to have it only show up when myproperty is not empty, I should wrap that div in {{#myproperty}} and {{/myproperty}}. I want it to display in one continuous block like the 'desc' property, so I basically copied the 'desc' CSS styling and just changed the name and text-align. After doing that (and a dozen iterations of that) I end up with two copies of 'myproperty' being displayed in the template. It DOES notice that myproperty is not empty, it does seem to recognize that myproperty is not just some random word but is a purposefully defined property and therefore displays it the way I wanted it formatted (one block and centered), BUT it also shows a duplicate of myproperty further up as if it is a random pair of 'key=value'. I've tried this with any number of other property names, I've tried moving the myproperty div into different parts of the template, etc, and I always get the weird duplicate entry. Any suggestions? My end goal is just to have one 'desc' that is left justified and one that is centered, and to be able to show them both simultaneously in one template. I thought the easiest way to do that would be to just copy 'desc' and give it a new name and new CSS. I was planning to change those property names to 'descleft' and 'desccenter' once I got this working. <rolltemplate class="sheet-rolltemplate-custom"> <div class="sheet-container sheet-color-{{color}}"> <div class="sheet-header"> {{#title}} <div class="sheet-title">{{title}}</div> {{/title}} {{#subtitle}} <div class="sheet-subtitle">{{subtitle}}</div> {{/subtitle}} </div> <div class="sheet-content"> {{#allprops() title subtitle desc color}} <div class="sheet-key">{{key}}</div> <div class="sheet-value">{{value}}</div> {{/allprops() title subtitle desc color}} {{#desc}} <div class="sheet-desc">{{desc}}</div> {{/desc}} {{#myproperty}} <div class="sheet-myprop">{{myproperty}}</div> {{/myproperty}} </div> </div> </rolltemplate> <button type="roll" name="roll_testroll" value="&{template:custom}{{title=this is the title}}{{subtitle=this is the subtitle}}{{random=random key, value}}{{this is unlabled}}{{desc=this is the description, aligned left}}{{myproperty=This is my property, centered}}">Click Me</button> <div style="width:400px;"> I can't figure out why when I add my own property to the rolltemplate, apparently following the directions in the wiki, the new property shows up twice... once as a 'key = value' (which is what should not be happening) and once as it should appear (all in one block, centered). I would expect it to behave exactly like the property 'desc', so I am not at all understanding why it is duplicating it as if it were a totally random 'key = value' </div> /* Jakob's Rolltemplate */ /* Smaller margins - remove these if you want the huge default left margin */ .sheet-rolltemplate-custom { margin-left: -37px; } .withoutavatars .sheet-rolltemplate-custom { margin-left: -7px; } .sheet-rolltemplate-custom .sheet-container { border: 1px solid; /* by default, the border is the same color as the header. You can change this here, e.g. to black */ border-color: var(--header-bg-color); } /* Header formatting - title and subtitle */ .sheet-rolltemplate-custom .sheet-header { background-color: var(--header-bg-color); /* change text-align to center to center the header text */ text-align: left; color: var(--header-text-color); padding: 5px; } .sheet-rolltemplate-custom .sheet-title { font-size:1.1em; } .sheet-rolltemplate-custom .sheet-subtitle { font-size:.9em; } /* example colors */ .sheet-rolltemplate-custom .sheet-container { /* this is the default color */ --header-bg-color: rgba(112,32,130,1); --header-text-color: #FFF; } .sheet-rolltemplate-custom .sheet-container.sheet-color-red { --header-bg-color: #F00; } .sheet-rolltemplate-custom .sheet-container.sheet-color-green { --header-bg-color: #0F0; --header-text-color: #000; } /* Allprops part */ .sheet-rolltemplate-custom .sheet-content { display: grid; background: #FFF; /* Header formatting - modify the column layout below */ grid-template-columns: auto auto; /* Line height to match default roll template */ line-height:1.4em; } .sheet-rolltemplate-custom .sheet-content > div { padding: 5px; } /* Left column */ .sheet-rolltemplate-custom .sheet-content .sheet-key { font-weight: bold; padding-right: 10px; text-align: right; } /* Empty rule, use this if you want to change the right column .sheet-rolltemplate-custom .sheet-value { } */ /* Make even-numbered rows grey */ .sheet-rolltemplate-custom .sheet-content :nth-child(4n+3), .sheet-rolltemplate-custom .sheet-content :nth-child(4n) { background:#EEE; } /* Description field */ .sheet-rolltemplate-custom .sheet-desc { grid-column: span 2; padding: 5px; text-align: left; } /* This is my own field which is acting quite strangely, duplicating itself as a random key=value*/ .sheet-rolltemplate-custom .sheet-myprop { grid-column: span 2; padding: 5px; text-align: center; } /* END JAKOB'S ROLLTEMPLATE */
1645704861
GiGs
Pro
Sheet Author
API Scripter
The problem is you have altered part of the rolltemplate, but not everywhere you need to. If you hardcode any extra properties (like your myproperty), you need to edit this section like so:      {{#allprops() title subtitle desc color myproperty}} <div class="sheet-key">{{key}}</div> <div class="sheet-value">{{value}}</div> {{/allprops() title subtitle desc color myproperty}} That section tells roll20 to print out every key in the roll, except these specified ones. Since you already have code elsewhere for those, it needs to be excluded here.
Ah ha! Thank you so much!
I wonder if the wiki could make that more clear, and perhaps earlier. I read the AllProps part about a dozen times, still didn't get it, and even knowing the solution now, that is not what I get from that part. Just a thought for future first-timers.
1645710481

Edited 1645710688
GiGs
Pro
Sheet Author
API Scripter
Sadly there's a lot that's hard to understand on the wiki, especially if you're not a programmer. I remember grasping what allprops did was pretty tricky for me, too, and I read the wiki entry several times and tried a bunch of code like you, before it finally registered. But the wiki is easily edited, do you have a suggestion for how that should be rewritten?
1645727083
vÍnce
Pro
Sheet Author
Made a little update to allprops() on the wiki: <a href="https://wiki.roll20.net/Building_Character_Sheets/Roll_Templates#Special_Helper_Function:_allProps.28.29" rel="nofollow">https://wiki.roll20.net/Building_Character_Sheets/Roll_Templates#Special_Helper_Function:_allProps.28.29</a> Might help others.&nbsp; Feel free to update/modify as needed.
I'm still learning to make myself understood in English, but I liked what you wrote GiGs. That would have definitely helped me, so I paraphrased it in the wiki. Anyone who needs to edit my entry for clarity will not offend me. This is what I added.... If the template you are using includes the Special Helper Function: allProps() described below, that section of the template tells Roll20 to print out every key and its value except the ones specified within the allProps() double curly brackets. If you have included formatting in the template for your new&nbsp; {{myproperty}} , you will probably want to add your&nbsp; {{myproperty}} &nbsp;to the list of properties to be ignored in this section, since you now already have code elsewhere for&nbsp; {{myproperty}} . Like so: {{#allprops() title subtitle desc color myproperty}} &lt;div class="sheet-key"&gt;{{key}}&lt;/div&gt; &lt;div class="sheet-value"&gt;{{value}}&lt;/div&gt; {{/allprops() title subtitle desc color myproperty}}