Skip to main content
added 468 characters in body
Source Link
Brad Bell
  • 67.6k
  • 6
  • 75
  • 145

It feels really random and I've no Ideaidea what's going wrong. Maybe someone has an idea.

{#

Prev / Next Link Examples:

{{ dh_macros.dh_postNav(entry, 'work', 'postDate', 'prev work', 'next work' ) }} #}

{% macro dh_postNav(entry, section, order, prevLabel, nextLabel ) %}

{# Set vars #} {% set section = section|default('blog') %} {% set order = order|default('postDate') %} {% set prevLabel = prevLabel|default(false) %} {% set nextLabel = nextLabel|default(false) %}

{# Set parameters for prev/next elements list #} {% set data = craft.entries.section(section).order(order).limit(null) %}

{# Get the prev/next elements #} {% set prevEntry = entry.getPrev(data) %} {% set nextEntry = entry.getNext(data) %}

{# And make sure to only output the links if the element exists #} {% if prevEntry or nextEntry %}

    Prev / Next Link
    Examples:

    {{ dh_macros.dh_postNav(entry, 'work', 'postDate', 'prev work', 'next work' ) }}
#}

    {% macro dh_postNav(entry, section, order, prevLabel, nextLabel ) %}

    {# Set vars #}
    {% set section     = section|default('blog') %}
    {% set order       = order|default('postDate') %}
    {% set prevLabel   = prevLabel|default(false) %}
    {% set nextLabel   = nextLabel|default(false) %}

    {# Set parameters for prev/next elements list #}
    {% set data = craft.entries.section(section).order(order).limit(null) %}

    {# Get the prev/next elements #}
    {% set prevEntry = entry.getPrev(data) %}
    {% set nextEntry = entry.getNext(data) %}

    {# And make sure to only output the links if the element exists #}
    {% if prevEntry or nextEntry %}

        <ul class="postNav">
            {% if prevEntry %}
                <li class="postNav__item  postNav__item--prev">
                    <a class="postNav__link  postNav__link--prev" href="{{ prevEntry.url }}">

                        {% if prevLabel != false %}
                            <span class="postNav__label">{{ prevLabel }}</span>
                        {% endif %}
      
                        <span class="postNav__title">{{ prevEntry.title }}</span>
                    </a>
                </li>
            {% endif %}
  
            {% if nextEntry %}
                <li class="postNav__item  postNav__item--next">
                    <a class="postNav__link  postNav__link--next" href="{{ nextEntry.url }}">
                        {% if nextLabel != false %}
                            <span class="postNav__label">{{ nextLabel }}</span>
                        {% endif %}
      
                        <span class="postNav__title">{{ nextEntry.title }}</span>
                    </a>
                </li>
            {% endif %}
        </ul>
    {% endif %}

{% endmacro %}

{% endif %}

{% endmacro %}

It feels really random and I've no Idea what's going wrong. Maybe someone has an idea.

{#

Prev / Next Link Examples:

{{ dh_macros.dh_postNav(entry, 'work', 'postDate', 'prev work', 'next work' ) }} #}

{% macro dh_postNav(entry, section, order, prevLabel, nextLabel ) %}

{# Set vars #} {% set section = section|default('blog') %} {% set order = order|default('postDate') %} {% set prevLabel = prevLabel|default(false) %} {% set nextLabel = nextLabel|default(false) %}

{# Set parameters for prev/next elements list #} {% set data = craft.entries.section(section).order(order).limit(null) %}

{# Get the prev/next elements #} {% set prevEntry = entry.getPrev(data) %} {% set nextEntry = entry.getNext(data) %}

{# And make sure to only output the links if the element exists #} {% if prevEntry or nextEntry %}

<ul class="postNav">
  {% if prevEntry %}
  <li class="postNav__item  postNav__item--prev">
    <a class="postNav__link  postNav__link--prev" href="{{ prevEntry.url }}">

      {% if prevLabel != false %}
      <span class="postNav__label">{{ prevLabel }}</span>
      {% endif %}
      <span class="postNav__title">{{ prevEntry.title }}</span>
    </a>
  </li>
  {% endif %}
  {% if nextEntry %}
  <li class="postNav__item  postNav__item--next">
    <a class="postNav__link  postNav__link--next" href="{{ nextEntry.url }}">
      {% if nextLabel != false %}
        <span class="postNav__label">{{ nextLabel }}</span>
      {% endif %}
      <span class="postNav__title">{{ nextEntry.title }}</span>
    </a>
  </li>
  {% endif %}
</ul>

{% endif %}

{% endmacro %}

It feels really random and I've no idea what's going wrong. Maybe someone has an idea.

{#
    Prev / Next Link
    Examples:

    {{ dh_macros.dh_postNav(entry, 'work', 'postDate', 'prev work', 'next work' ) }}
#}

    {% macro dh_postNav(entry, section, order, prevLabel, nextLabel ) %}

    {# Set vars #}
    {% set section     = section|default('blog') %}
    {% set order       = order|default('postDate') %}
    {% set prevLabel   = prevLabel|default(false) %}
    {% set nextLabel   = nextLabel|default(false) %}

    {# Set parameters for prev/next elements list #}
    {% set data = craft.entries.section(section).order(order).limit(null) %}

    {# Get the prev/next elements #}
    {% set prevEntry = entry.getPrev(data) %}
    {% set nextEntry = entry.getNext(data) %}

    {# And make sure to only output the links if the element exists #}
    {% if prevEntry or nextEntry %}

        <ul class="postNav">
            {% if prevEntry %}
                <li class="postNav__item  postNav__item--prev">
                    <a class="postNav__link  postNav__link--prev" href="{{ prevEntry.url }}">

                        {% if prevLabel != false %}
                            <span class="postNav__label">{{ prevLabel }}</span>
                        {% endif %}
      
                        <span class="postNav__title">{{ prevEntry.title }}</span>
                    </a>
                </li>
            {% endif %}
  
            {% if nextEntry %}
                <li class="postNav__item  postNav__item--next">
                    <a class="postNav__link  postNav__link--next" href="{{ nextEntry.url }}">
                        {% if nextLabel != false %}
                            <span class="postNav__label">{{ nextLabel }}</span>
                        {% endif %}
      
                        <span class="postNav__title">{{ nextEntry.title }}</span>
                    </a>
                </li>
            {% endif %}
        </ul>
    {% endif %}

{% endmacro %}
added 1729 characters in body
Source Link

I've this macro:

{{ dh_macros.dh_postNav(entry, 'blog', 'postDate', 'prev article', 'next article') }}

I call it on my blog/_single template and it works for 90% of the posts. But the newest 6 posts doesn't show the next / prev links.

enter image description here

This is the last post how it works fine. In the next newer post it looks like this: enter image description here

Here is the next post link missing. And one post newer there is no link shown neither next nor prev :/

To appreciation, there are next / prev posts there.

It feels really random and I've no Idea what's going wrong. Maybe someone has an idea.

Thanks!

Here the Full Code maybe someone need it:

{#

Prev / Next Link Examples:

{{ dh_macros.dh_postNav(entry, 'work', 'postDate', 'prev work', 'next work' ) }} #}

{% macro dh_postNav(entry, section, order, prevLabel, nextLabel ) %}

{# Set vars #} {% set section = section|default('blog') %} {% set order = order|default('postDate') %} {% set prevLabel = prevLabel|default(false) %} {% set nextLabel = nextLabel|default(false) %}

{# Set parameters for prev/next elements list #} {% set data = craft.entries.section(section).order(order).limit(null) %}

{# Get the prev/next elements #} {% set prevEntry = entry.getPrev(data) %} {% set nextEntry = entry.getNext(data) %}

{# And make sure to only output the links if the element exists #} {% if prevEntry or nextEntry %}

<ul class="postNav">
  {% if prevEntry %}
  <li class="postNav__item  postNav__item--prev">
    <a class="postNav__link  postNav__link--prev" href="{{ prevEntry.url }}">

      {% if prevLabel != false %}
      <span class="postNav__label">{{ prevLabel }}</span>
      {% endif %}
      <span class="postNav__title">{{ prevEntry.title }}</span>
    </a>
  </li>
  {% endif %}
  {% if nextEntry %}
  <li class="postNav__item  postNav__item--next">
    <a class="postNav__link  postNav__link--next" href="{{ nextEntry.url }}">
      {% if nextLabel != false %}
        <span class="postNav__label">{{ nextLabel }}</span>
      {% endif %}
      <span class="postNav__title">{{ nextEntry.title }}</span>
    </a>
  </li>
  {% endif %}
</ul>

{% endif %}

{% endmacro %}

I've this macro:

{{ dh_macros.dh_postNav(entry, 'blog', 'postDate', 'prev article', 'next article') }}

I call it on my blog/_single template and it works for 90% of the posts. But the newest 6 posts doesn't show the next / prev links.

enter image description here

This is the last post how it works fine. In the next newer post it looks like this: enter image description here

Here is the next post link missing. And one post newer there is no link shown neither next nor prev :/

To appreciation, there are next / prev posts there.

It feels really random and I've no Idea what's going wrong. Maybe someone has an idea.

Thanks!

I've this macro:

{{ dh_macros.dh_postNav(entry, 'blog', 'postDate', 'prev article', 'next article') }}

I call it on my blog/_single template and it works for 90% of the posts. But the newest 6 posts doesn't show the next / prev links.

enter image description here

This is the last post how it works fine. In the next newer post it looks like this: enter image description here

Here is the next post link missing. And one post newer there is no link shown neither next nor prev :/

To appreciation, there are next / prev posts there.

It feels really random and I've no Idea what's going wrong. Maybe someone has an idea.

Thanks!

Here the Full Code maybe someone need it:

{#

Prev / Next Link Examples:

{{ dh_macros.dh_postNav(entry, 'work', 'postDate', 'prev work', 'next work' ) }} #}

{% macro dh_postNav(entry, section, order, prevLabel, nextLabel ) %}

{# Set vars #} {% set section = section|default('blog') %} {% set order = order|default('postDate') %} {% set prevLabel = prevLabel|default(false) %} {% set nextLabel = nextLabel|default(false) %}

{# Set parameters for prev/next elements list #} {% set data = craft.entries.section(section).order(order).limit(null) %}

{# Get the prev/next elements #} {% set prevEntry = entry.getPrev(data) %} {% set nextEntry = entry.getNext(data) %}

{# And make sure to only output the links if the element exists #} {% if prevEntry or nextEntry %}

<ul class="postNav">
  {% if prevEntry %}
  <li class="postNav__item  postNav__item--prev">
    <a class="postNav__link  postNav__link--prev" href="{{ prevEntry.url }}">

      {% if prevLabel != false %}
      <span class="postNav__label">{{ prevLabel }}</span>
      {% endif %}
      <span class="postNav__title">{{ prevEntry.title }}</span>
    </a>
  </li>
  {% endif %}
  {% if nextEntry %}
  <li class="postNav__item  postNav__item--next">
    <a class="postNav__link  postNav__link--next" href="{{ nextEntry.url }}">
      {% if nextLabel != false %}
        <span class="postNav__label">{{ nextLabel }}</span>
      {% endif %}
      <span class="postNav__title">{{ nextEntry.title }}</span>
    </a>
  </li>
  {% endif %}
</ul>

{% endif %}

{% endmacro %}

Source Link

Prev / Next Link Problem

I've this macro:

{{ dh_macros.dh_postNav(entry, 'blog', 'postDate', 'prev article', 'next article') }}

I call it on my blog/_single template and it works for 90% of the posts. But the newest 6 posts doesn't show the next / prev links.

enter image description here

This is the last post how it works fine. In the next newer post it looks like this: enter image description here

Here is the next post link missing. And one post newer there is no link shown neither next nor prev :/

To appreciation, there are next / prev posts there.

It feels really random and I've no Idea what's going wrong. Maybe someone has an idea.

Thanks!