Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
markup dump
I think its about time we drop the <ul> <li>
facination it dosnt really make sense imho
<nav class="pager">
<span class="first"><a href="foo" title="Go to first page">« </a></span>
<span class="pre"><a href="foo?page=2" title="Go to previous page">‹ </a></span>
<span><a href="foo" title="Go to page 1">1</a></span>
<span><a href="foo?page=1" title="Go to page 2">2</a></span>
<span><a href="foo?page=2" title="Go to page 3">3</a></span>
<span class="active"><b>4</b></span>
<span><a href="foo?page=4" title="Go to page 5">5</a></span>
<span><a href="foo?page=5" title="Go to page 6">6</a></span>
<span><a href="foo?page=6" title="Go to page 7">7</a></span>
<span><a href="foo?page=7" title="Go to page 8">8</a></span>
<span><a href="foo?page=8" title="Go to page 9">9</a></span>
<span>…</span>
<span class="next"><a href="foo?page=4" title="Go to next page"> ›</a></span>
<span class="last"><a href="foo?page=18334" title="Go to last page"> »</a></span>
</nav>
pager.html.twig:
{#
need the following variables
first
previous
last
next
ellipsis
page_count
current
#}
{% if pager %}
<nav class="pager">
{% if first is defined %}
<span class="first">
<a href="{{ url }}" title=" {{ help text }}">« </a>
</span>
{% endif %}
{% if previous is defined %}
<span class="pre">
<a href="{{ url }}" title=" {{ help text }}">‹ </a>
</span>
{% endif %}
{% for page in page_count %}
{% if page != current %}
<span>
<a href="{{ url }}" title=" {{ help text }}">{{ count }}</a>
</span>
{% else %}
<span class="active"><b>{{ count }}</b></span>
{% endif %}
{% endfor %}
{% if ellipsis is defined %}
<span>...</span>
{% endif %}
{% if next is defined %}
<span class="next">
<a href="{{ url }}" title=" {{ help text }}"> ›</a>
</span>
{% endif %}
{% if last is defined %}
<span class="last">
<a href="{{ url }}" title=" {{ help text }}"> »</a>
</span>
{% endif %}
</nav>
{% endif %}
got pointed to some good info here about pagers at the sprint in sydney
https://github.com/KnpLabs/KnpPaginatorBundle
Comments
Comment #1
steveoliver CreditAttribution: steveoliver commentedi suppose so — pagers are never going to be hierarchical :)
Comment #2
jwilson3This seems like a duplicate of #1912608: Update pagination markup for new CSS standards and improved accessibility.
Comment #3
jwilson3The sample code above is also missing rel=prev and rel=next.
Comment #4
jwilson3morten, since you copied your comment from here already over to the other one, lets just call this a dupe.
Comment #4.0
jwilson3link to inspiration