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

Martin
  • 1,203
  • 8
  • 18

1 Answers1

1

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

{% if page.pageIntroText is not empty %}

Aaron Berkowitz
  • 3,819
  • 10
  • 20
a-am
  • 2,857
  • 1
  • 19
  • 25
  • Thanks for your suggestion... it didn't work. I now have this: {% nav page in subnav %}
  • {% if page.pageIntroText is not empty %} {{ page.title }} {% else %} {{ page.title }} {% endif %}
  • {% endnav %} – Martin Oct 27 '15 at 19:47
  • Bizarre! I've just tried using a different field for the conditional and it's worked fine??? – Martin Oct 27 '15 at 19:50
  • What type of input is pageIntroText? I assumed it was Plain or Rich Text. – a-am Oct 27 '15 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 '15 at 04:32