Can I insert specific buttons based on labels and have a fallback
Hi Zendesk Community!
I am working on inserting buttons on all pages of our help center at the bottom of the page. It seems to be most viable to do this in scripting language. BUT I can came across a challenge with having a fallback button, if the labels do not meet the requirements.
Logic I want to achieve is:
- Loop through labels
- Check for specific values
- Insert buttons based on these values
- If the label of the article does not meet that, insert a fallback button.
I have the 3 first steps working fine, I just can't figure out a way to achieve a fallback so I can ensure a button on all article pages.
The short version: Any advice on how I can add a single fallback button based on article labels?
See my code for reference:
<!--Dynamically add buttons based on labels that link to commercial sites-->
{{#if article.labels}}
{{#each article.labels}}
{{#is identifier 'dtc_forside'}}
<div style="text-align:center">
<button type="button" onClick="javascript:window.open('#', '_blank');" class="dtcbutton">TEXT</button>
</div>
{{/is}}
{{#is identifier 'dtc_checkout'}}
<div style="text-align:center">
<button type="button" onClick="javascript:window.open('#', '_blank');" class="dtcbutton">TEXT</button>
</div>
{{/is}}
{{#is identifier 'dtc_mittv2'}}
<div style="text-align:center">
<button type="button" onClick="javascript:window.open('#', '_blank');" class="dtcbutton">TEXT</button>
</div>
{{/is}}
{{/each}}
{{/if}}
-
Please, replace the below code with your current one and it will help you to add a fallback button.
<!--Dynamically add buttons based on labels that link to commercial sites-->
{{#if article.labels}}
{{#each article.labels}}
{{#is identifier 'dtc_forside'}}
<div style="text-align:center">
<button type="button" onClick="javascript:window.open('#', '_blank');" class="dtcbutton">TEXT</button>
</div>
{{/is}}
{{#is identifier 'dtc_checkout'}}
<div style="text-align:center">
<button type="button" onClick="javascript:window.open('#', '_blank');" class="dtcbutton">TEXT</button>
</div>
{{/is}}
{{#is identifier 'dtc_mittv2'}}
<div style="text-align:center">
<button type="button" onClick="javascript:window.open('#', '_blank');" class="dtcbutton">TEXT</button>
</div>
{{/is}}
{{/each}}
{{else}}
<div style="text-align:center">
<button type="button" onClick="javascript:window.open('#', '_blank');" class="dtcbutton">Alt TEXT</button>
</div>
{{/if}}Let me know if it solves your issue
Thank You
Pulkit
Team Diziana
-
Hi Pulkit Pandey
Thank you, this is what I was looking for :)
Por favor, entrar para comentar.
2 Comentários