3

I'm using this solution to output the children within a current structure entry. Unfortunately I need to take out the anchor on some entries that don't yet have content, but still include the (unlinked) title.

I'm trying the following

{% nav page in subnav  %}
  {% if page.id != entry.id %}
  <li>{% if page.pageIntroText|length %}<a href="{{ page.url }}">{%endif%}{{ page.title }}{% if page.pageIntroText|length %}</a>{%endif%}</li>
  {%else%}
  <li class="current-page">{{ page.title }}</li>{%endif%}
{% endnav %}

.. but it removes the anchor regardless of whether there is any content in pageIntroText field?

Any ideas?

Many thanks

Martin

1 Answer 1

1

Instead of using {% if page.pageIntroText|length %} have you tried

{% if page.pageIntroText is not empty %}

4
  • Thanks for your suggestion... it didn't work. I now have this: {% nav page in subnav %} <li> {% if page.pageIntroText is not empty %} <a href="{{ page.url }}">{{ page.title }}</a> {% else %} {{ page.title }} {% endif %} </li> {% endnav %}
    – Martin
    Oct 27, 2015 at 19:47
  • Bizarre! I've just tried using a different field for the conditional and it's worked fine???
    – Martin
    Oct 27, 2015 at 19:50
  • What type of input is pageIntroText? I assumed it was Plain or Rich Text.
    – a-am
    Oct 27, 2015 at 20:04
  • I'm an idiot! I have two fields, pageIntroText and practiceIntroText, this section is querying practiceIntroText. Thanks for your help :/
    – Martin
    Oct 28, 2015 at 4:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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