2

I have a blog where page one has a big "feature" thumbnail and after that each subsequent thumbnail is half the size. I want that to only happen on page one, which i have done using:

{% if paginate.currentPage == 1 and loop.index == 1 %}

That works perfectly fine.

The problem is that because of this design choice, page one shows 13 entries, but page two onward needs to show 12, otherwise it will look wonky! Any ideas on how i could achieve this?

7

There's an offset parameter that allows you to skip the first entries from your ElementCriteriaModel.

You would set up two nearly identical ElementCriteriaModels, one exclusivly for your featured entry, using the first() method to only query for the first entry, and to the second one you'd add offset(1) as a parameter, to get all the other entries for your pagination.

{% set params = { section: 'blog' } %}

{# Get the featured entry #}
{% set featuredEntry = craft.entries(params).first() %}

{# Get all the other entries #}
{% set entries = craft.entries(params).offset(1).limit(10) %}

{% paginate entries as entriesOnPage %}

    {# Show featured entry on page one #}
    {% if paginate.currentPage == 1 %}
        <img src="{{ featuredEntry.url('fullwidth') }}" class="fullwidth">
    {% endif %}

    {% for entry in entriesOnPage %}
        <img src="{{ entry.url('thumb') }}" class="thumb">
    {% endfor %}

{% endpaginate %}
| improve this answer | |
  • Thank you very much! You've made it really nice and easy to understand, and it works like a charm :^) – Dan Owen Jan 29 '15 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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