Skip to content

Instantly share code, notes, and snippets.

@kaspar-allenbach
Created January 30, 2018 14:08
Show Gist options
  • Save kaspar-allenbach/9733cbebc9ea34539a0232eeab2295b6 to your computer and use it in GitHub Desktop.
Save kaspar-allenbach/9733cbebc9ea34539a0232eeab2295b6 to your computer and use it in GitHub Desktop.
Craft CMS Pagination
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
.blogPagination {
display: flex;
justify-content: space-between;
a {
display: block;
&:nth-child(odd):before {
content: "";
background-image: url('/theme/img/arrow.svg');
width: 20px;
height: 20px;
position: absolute;
transform: rotate(180deg);
transform-origin: 50% 48%;
margin-left: -30px;
}
&:nth-child(even):after {
content: "";
background-image: url('/theme/img/arrow.svg');
width: 20px;
height: 20px;
position: absolute;
margin-left: 10px;
}
}
}
{# Set parameters for prev/next elements list #}
{% set params = craft.entries.section('blogEntry').order('title asc') %}
{# Get the prev/next elements #}
{% set prevEntry = entry.getPrev(params) %}
{% set nextEntry = entry.getNext(params) %}
{# And make sure to only output the links if the element exists #}
<div class="blogPagination">
{% if prevEntry %}
<a href="{{ prevEntry.url }}">
{{ prevEntry.title }}
</a>
{% endif %}
{% if nextEntry %}
<a href="{{ nextEntry.url }}">
{{ nextEntry.title }}</a>
{% endif %}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment