2

I thought this would be easy. I cut and pasted code that works from the Mijingo Happy Lager tutorial site. But, I keep getting the template error below.

My code...

{% paginate craft.entries.section('posts').limit(8) as postEntries %}

    {% for post in postEntries %}

        <div class="element-item {{post.isotope}} box col-md-3 ">
            <div class="post-box vertical clearfix">
                <a href="{{ post.url }}" class="image-link arrow-icon dark-overlay"><img src="{{ post.postImage.first().getUrl('thumbImage')}}" width="434" height="434" alt=""></a>

                <div class="extra-info">                                    
                    <h5><a href="{{ post.url }}">{{ post.title}}</a></h5>

                    <p class="meta small">{{ post.postDate | date('F d, Y') }}</p>
                    <a href="{{post.url}}" class="go-to-arrow"><i class="fa fa-arrow-circle-o-right fa-2x" aria-hidden="true"></i></a>

                </div>
            </div>
        </div>
    {% endfor %}

    <div class="pagination">
        <ul>
            {% if paginate.prevUrl %}
                <li><a href="{{ paginate.prevUrl }}" class="pag-prev-link">Previous Page</a></li>
            {% endif %}

            {% for page, url in paginate.getPreviousUrls(5) %}
                <li><a href="{{ url }}">{{ page }}</a></li>
            {% endfor %}

            <li class="current">{{ paginate.currentPage }}</li>

            {% for page, url in paginate.getNextUrls(5) %}
                <li><a href="{{ url }}">{{ page }}</a></li>
            {% endfor %}

            {% if paginate.nextUrl %}
                <li><a href="{{ paginate.nextUrl }}" class="pag-next-link">Next Page</a></li>
            {% endif %}
        </ul>
    </div>

{% endpaginate %}   

The error message...

Neither the property "getPreviousUrls" nor one of the methods "getPreviousUrls()", "getgetPreviousUrls()"/"isgetPreviousUrls()" or "__call()" exist and have public access in class "Craft\PaginateVariable"

What am I forgetting?

1

Not sure about the Mijingo tutorial, but pretty sure you need to change this:

{% paginate craft.entries.section('posts').limit(8) as postEntries %}

To this:

{% paginate craft.entries.section('posts').limit(8) as paginate, postEntries %}

If that doesn't work, then there is probably a conflict with your using paginate as a variable inside the {% paginate %} tag.

You should update it to be something else like the example in the pagination docs.

2
  • It does not work. – Hellyar Oct 23 '16 at 20:38
  • But the pagination docs approach works. Good enough for me. – Hellyar Oct 23 '16 at 20:52
2

A couple of years later, I ran into the same issue. In case there are others looking, it looks like this line:

{% for page, url in paginate.getPreviousUrls(5) %}

Should be:

{% for page, url in paginate.getPrevUrls(5) %}

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.