TypeError: Cannot read property 'number' of undefined
epszaw opened this issue · 1 comments
epszaw commented
Hey guys!
I have some troubles with generation "paged" pages.
I try use example and have error:
TypeError: Cannot read property 'number' of undefined
Example code:
<!-- Page Content -->
<% for document in @getPageCollection('posts').toJSON(): %>
<article id="post" class="post">
<h1><a href='<%=document.url%>'><%= document.title %></a></h1>
<div class="post-date"><%= document.date.toLocaleDateString() %></div>
<div class="post-content">
<%- document.contentRenderedWithoutLayouts %>
</div>
</article>
<% end %>
<!-- Page Listing -->
<div class="pagination">
<ul>
<!-- Previous Page Button -->
<% unless @hasPrevPage(): %>
<li class="disabled"><span>Prev</span></li>
<% else: %>
<li><a href="<%= @getPrevPage() %>">Prev</a></li>
<% end %>
<!-- Page Number Buttons -->
<% for pageNumber in [0..@document.page.count-1]: %>
<% if @document.page.number is pageNumber: %>
<li class="active"><span><%= pageNumber + 1 %></span></li>
<% else: %>
<li><a href="<%= @getPagedUrl(pageNumber) %>"><%= pageNumber + 1 %></a></li>
<% end %>
<% end %>
<!-- Next Page Button -->
<% unless @hasNextPage(): %>
<li class="disabled"><span>Next</span></li>
<% else: %>
<li><a href="<%= @getNextPage() %>">Next</a></li>
<% end %>
</ul>
</div>
On meta-data of layout page, I paste:
pagedCollection: 'posts'
pageSize: 5
order: 1
isPaged: true
How I can solve this error?
epszaw commented
I solve this problem.
Other file recalls this template file and this template has parameters from file.