Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Allan Hawkey 232 posts 303 karma points
    Sep 15, 2011 @ 11:02
    Allan Hawkey
    0

    2.0 beta - pagination not working

    I'm populating a blog using 2.0 beta, and have entered 10 posts so far.

    On the landing page, the first 5 are displayed - but the pagination shows Prev 0 Next, but no way to access the next page (there are no links on Prev or Next, and the 0 links back to page 0 - presumably the default landing page).

    Any ideas how to correct this?

    Thanks
    Allan

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Sep 22, 2011 @ 22:38
    Anthony Dang
    0

    Sorry for the delayed response. 

    I'll fix this in the next release.

     

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Sep 22, 2011 @ 23:56
    Anthony Dang
    0

    Try replacing the pagination helper method with this one.

     


    @helper RenderPagination(int page, int postCount, int itemsPerPage) { int pages = (int)Math.Ceiling((double)postCount / (double)itemsPerPage); string url = Request.Url.ToString(); string querystring = Request.Url.Query; <ul id="uBlogsy_pagination"> @* render prev link *@ <li class="uBlogsy_page_prev"> @if (page > 0) { url = url.ReplaceQueryStringItem("page", (page - 1).ToString()); <a href="@url" >Prev</a> }else{ <span>Prev</span> } </li> @* render page links *@ @for (int i = 0; i < pages; i++) { url = url.ReplaceQueryStringItem("page", i.ToString()); string liClass = i == page ? "uBlogsy_current" : string.Empty; <li class="uBlogsy_page_item @liClass"> @if(page == i){ <span>@i</span> }else{ <a href="@url">@i</a> } </li> } @* render next link *@ <li class="uBlogsy_page_next"> @if (page < (postCount/itemsPerPage)) { url = url.ReplaceQueryStringItem("page", (page + 1).ToString()); <a href="@url" >Next</a> } else { <span>Next</span> } </li> </ul> }




  • Allan Hawkey 232 posts 303 karma points
    Sep 22, 2011 @ 23:57
    Allan Hawkey
    0

    thanks - any idea when the next release is likely to be available?

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Sep 23, 2011 @ 00:15
    Anthony Dang
    0

    some time before november, then hopefully a full full full release not too long after that.

     

  • Barry Fogarty 493 posts 1129 karma points
    Sep 23, 2011 @ 00:20
    Barry Fogarty
    0

    FYI I also plugged in Sebastiaan's excellent (and simple) pager into v.1.32 and it works like a charm.

  • Allan Hawkey 232 posts 303 karma points
    Sep 27, 2011 @ 14:42
    Allan Hawkey
    0

    Hi Anthony

    I've replaced the pagination helper method as you suggested but am still having trouble - I think the problem was due to the const int ITEMS_PER_PAGE = 20; in uBlogsyListPosts.cshtml.

    I had changed the number of items to display per page to 5 in the macro on the landing page template, but the ITEMS PER PAGE were still set to 20.  So the pagination thought there would be just one page (as there were fewer than 20 posts) but the page only displayed 5 items.

    As a suggestion, it would probably be an enhancement if this could be entered in just one place, rather than having to update two places if you want to change the number of posts displayed on each page.

    Thanks
    Allan

Please Sign in or register to post replies

Write your reply to:

Draft