Copied to clipboard

Flag this post as spam?

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


  • Nelson 94 posts 246 karma points
    Jan 29, 2016 @ 06:10
    Nelson
    0

    Paging in Umbraco

    Hello guys,

    how's the best way to create paging in Umbraco? Can I apply the paging system to the pages of my choice?

    Thank you very much!

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Jan 29, 2016 @ 06:31
    Nicholas Westby
    0

    Could you add some more details? What type of paging are you talking about? Do you have a link or screenshot of an example you are trying to implement? What factors are you considering when you think of the "best way" (e.g., performance)?

  • Nelson 94 posts 246 karma points
    Jan 29, 2016 @ 07:06
    Nelson
    0

    The paging I would like to have is something like the following:

    | 1 | | 2 | | 3 | | 4 | ... | 50 |

    each page number is a colored box. What I want is a really simple solution for paging. When I say best way is more about the simplest method to implement.

    Thank you for your answer!

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Jan 29, 2016 @ 08:28
    Nik
    0

    Hi Nelson,

    I believe (although I may be incorrect) that there are snippets in Umbraco for Paging. I would check in the Partial View Macros when you try to create a new one.

  • Nelson 94 posts 246 karma points
    Jan 29, 2016 @ 09:54
    Nelson
    0

    Already searched but don't seem to find an updated one, the ones I found out are deprecated.

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Jan 30, 2016 @ 06:34
    Nicholas Westby
    0

    Still not sure what your question is. Are you paging search results?

    As far as rendering out a pager, here's how it's done with Bootstrap: http://getbootstrap.com/components/#pagination

    There's nothing particularly special about doing that in Umbraco, but it depends on what in particular you are paging.

  • Nelson 94 posts 246 karma points
    Feb 01, 2016 @ 06:07
    Nelson
    0

    I have a list of products to display in my page, and want to add paging to it, that it! So with Bootsrap I dont need to do much with Umbraco right? But its not possible to have dynamic paging with bootstrap right? You just create the pages and put the href link in each page of the paging. I would like to have a dynamic paging.

    Thanks for your answer!

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Feb 01, 2016 @ 06:17
    Nicholas Westby
    0

    As far as Umbraco goes, it's pretty typical. Render out a list of "pages" (i.e., numbers"). Each would be a link with a query string indicating the page (e.g., "?page=3"). Set an active class on one of the based on the current page in the query string.

    If you have any issues writing the code for this, write a reply here with the code you are using and we'll assist as necessary.

  • Nelson 94 posts 246 karma points
    Feb 03, 2016 @ 06:18
    Nelson
    0

    I've found a snippet, but I'm having some errors because I'm using LeBlender for my grid editors. Here's my code:

    @inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
    @{
    var pageSize = 6;
    if(Model.Content.HasValue("numberOfItemsPerPage")){
        pageSize = Model.Content.GetPropertyValue<int>("numberOfItemsPerPage");
    }
    var page = 1; int.TryParse(Request.QueryString["page"], out page);
    var items = Model.Items;
    var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);
    
    if (page > totalPages)
    {
        page = totalPages;
    }
    else if (page < 1)
    {
        page = 1;
    }
    
    
    foreach(var item in items.Skip((page - 1) * pageSize).Take(pageSize).OrderBy(x=>x.Name)){
    
         <div class="work-item work-item-box">
            <a [email protected](item.GetValue<string>("workPage")).Url>
                <img class="work-item-image" [email protected](item.GetValue<string>("image")).Url height="180" width="310"/>
            </a>
        </div>      
    }
    
    
    if (totalPages > 1)
    {
        <div class="pagination">
            <ul>
                @if (page > 1)
                {
                    <li><a href="?page=@(page-1)">Prev</a></li>
                }
                @for (int p = 1; p < totalPages + 1; p++)
                {
                    <li class="@(p == page ? "active" : string.Empty)">
                        <a href="?page=@p">@p</a>
                    </li>
                }
                @if (page < totalPages)
                {
                    <li><a href="?page=@(page+1)">Next</a></li>
                }
            </ul>
        </div>
    }
    

    }

    And I got this error: c:...\umbraco\Views\Partials\Work.cshtml(5): error CS1061: 'Lecoati.LeBlender.Extension.Models.LeBlenderModel' does not contain a definition for 'Content' and no extension method 'Content' accepting a first argument of type 'Lecoati.LeBlender.Extension.Models.LeBlenderModel' could be found (are you missing a using directive or an assembly reference?)

  • Nelson 94 posts 246 karma points
    Mar 08, 2016 @ 06:58
    Nelson
    0

    Anyone can help please?

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Mar 18, 2016 @ 02:56
    Nicholas Westby
    0

    Since it seems you are using a strongly typed model of type LeBlenderModel, your model would no longer have a Content property on it. You would need to access data from the LeBlenderModel.

Please Sign in or register to post replies

Write your reply to:

Draft