Insert a button if the article has a specific label | Community
Skip to main content

Insert a button if the article has a specific label

  • December 19, 2022
  • 3 replies
  • 0 views

Hi Community! 

I am attempting to insert a button at the end of articles if they have a certain label on it. 

Any pointers to how this can be achieved? 

I tried something like this, which doesnt seem to do the trick.

 

 <div class="content-body article-body">
 {{article.body}}
</div>
<div>
 {{#if article.labels}}
   {{#each (filter article.labels on 'identifier' equals="specific label")}}
     <div>
       <button type="button" onClick="javascript:window.open('https://###', '_blank');" class="x">Text</button>
     </div>
   {{/each}}
 {{/if}}
</div>

 

3 replies

Pulkit12
  • December 19, 2022

Hi Søren Dahl Poulsen

Please add the below-updated code to add a button on the article page when the article has a specific label on it.

<div class="content-body article-body">
{{article.body}}
</div>
<div>
{{#if article.labels}}
{{#each article.labels}}
{{#is identifier 'CR7'}}
<div>
<button type="button" onClick="javascript:window.open('https://###', '_blank');" class="x">Text</button>
</div>
{{/is}}
{{/each}}
{{/if}}
</div>

Note: Please replace the CR7 with your targeted label name 

 

Thanks 

Pulkit

Team Diziana

 


  • Author
  • December 20, 2022

Thank you very much @pulkit12
That did the trick :) 


Pulkit12
  • December 20, 2022

Hi Søren Dahl Poulsen

Happy to hear that :)

 

Thanks 

Pulkit