1

I want to add if condition in my "global custom text" field saying if node is published, print some link. I tried below steps , but it is not working: 1.I have added "Content: Publishing status" field and hidden it from display 2.In 'global custom text' field added below code: Replacement pattern for published status is {{ status }} and is returning 0 or 1. Code I added is:

  {% if  status  ==0 %}
    <div class="apply_job"><a href="/appy-job" target="_blank"> APPLY
 </a></div>
    {% endif %}

Drupal Version:8.2.0

Can anybody help me to make this working? Thank you In Advance

0

I try that right now and worked for me.

enter image description here Note: just make sure set Output format to 0/1

{% if  status  %}
   <div class="apply_job"><a href="/appy-job" target="_blank"> APPLY </a></div>
{% endif %}

enter image description here

  • thanks for the reply, but same code is not working in mine.My status field output format is boolean only. If node is unpublished also link is getting displayed. I have updated my question with the version of drupal 8. – rks Mar 31 '17 at 4:01
  • @rks what you mean, you can see in my answer my field is boolean too and my drupal version in 8.2.6. do you want not exclude status field from display? – Yusef Mohamadi Mar 31 '17 at 6:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.