How can I say like I only wan't to have 1 item per page and not more?
If you want to scroll through the rest, you need to use the buttons below (older and newer).
I've searched the web and forum and come across a few options, but none seems to work on my site...
var items = CurrentPage.Site().FirstChild("ProjectPage").Children.Where("Visible");
But, I have some other issues now with the pagenation. It doens't show the page number correctly. (they are all 1 instead of 1, 2, 3, 4) and the browsing doesn't work.
Hi,
how to implemente pagination(need to show 50 dealer per page) in umbraco cms v7.7
please provide step by setp process because i was new to this cms
Pagination on site
Hi all,
I'm searching for a good, fast and easy way to implement a pagination on my sites. As an example you can see on my test site two test projects.
http://brouwerij.gregoir.be/bieren/
How can I say like I only wan't to have 1 item per page and not more? If you want to scroll through the rest, you need to use the buttons below (older and newer).
I've searched the web and forum and come across a few options, but none seems to work on my site...
Could anybody help me?
Thanks!
Laurens
Hi Laurens,
Can you maybe post the code you have right now. Then we can start from there.
Dave
Hi Dave,
I've used this as a starting point. https://our.umbraco.org/forum/developers/razor/41166-Razor-Paging-snippet
I know that I need to change the .IsDocumentType("xxxxx") to my page name. I did that, but nothing is working...
@{Layout = "MasterTemplate.cshtml";} @{ var pageSize = 3; var page = 1; int.TryParse(Request.QueryString["p"], out page); var items = Model.Content.Children().Where(x => x.IsDocumentType("BlogPost")).OrderByDescending(x => x.CreateDate); var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);
}
@if (page > 1) {- Prev
}
@for (int p = 1; p < totalPages + 1; p++)
{
var active = (p == page) ? "active" : string.Empty;
-
1
}
@if (page < items.Count())
{
- Next
}
Code seems fine. Maybe you can change the where clause to this to see if it helps
.Where(x => x.DocumentTypeAlias == "TheAliasOfYourDoctype")
Hi Dave,
I've tried your suggested change. However I now get an error.
So how I basically work with the partial is like this:
Under settings:
Templates -> Master -> Project Page I have a renderpartial that's being called upon.
@{ Html.RenderPartial("Pagination"); }
The partial is listed under Partial views -> Pagination and contains the code for the pagination itself.
It looks like you implemented my code wrong.
It should be : .Where(x => x.DocumentTypeAlias == "TheAliasOfYourDoctype")
Oh my mistake. Apologies.
I've changed it and now I don't have an error anymore. But it still isn't working I'm afraid..
Maybe stupid question. But how many items do you have ? I only see 2, but you set your page size to 3. Try setting it to 1.
I've created 5 more test pages (so now 7 in total) and changed the pagesize to 1 for testing. The pagenation field is still empty.
It's like it's looking in the wrong section and can't find anything to list.
Can you try to out put the values from page totalpage
Hmm, if you now go to http://brouwerij.gregoir.be/bieren/ you will see the result of the requested.
Seems it has a problem with the items.
items = System.Linq.OrderedEnumerable`2[Umbraco.Core.Models.IPublishedContent,System.DateTime]
Can you add .ToList() add the end of this line where you get the items ?
Still the same error.
items = @items.ToList()
items = System.Collections.Generic.List`1[Umbraco.Core.Models.IPublishedContent]
It seems that there is something wrong with the calculation of total pages. It says it's 0
I think there is an issue in the code to fetch the page.
var items = Model.Content.Children().Where(x => x.DocumentTypeAlias == "ProjectPage").OrderByDescending(x => x.CreateDate).ToList();
That's why it can't count the total pages and shows 0.
Okay, seems that this is working:
var items = CurrentPage.Site().FirstChild("ProjectPage").Children.Where("Visible");
But, I have some other issues now with the pagenation. It doens't show the page number correctly. (they are all 1 instead of 1, 2, 3, 4) and the browsing doesn't work.
Nor does my previous button shows :p
But we are getting there :)
Okay, fixed the page numbering.
Nearly there, but my previous buttons is still missing and my content is not changing per page..
Can you show your code again like you have it now ?
Dave
Sure Dave,
Here is the link to the code.
http://pastebin.com/0FrWNZ8F
I see the problem. You check on querystring parameter "p" to get the current page. While the actual querystring parameter is "page".
So change it to this : int.TryParse(Request.QueryString["page"], out page);
Dave
That did it!
One last thing, is it possible to hide the "next" button when it reaches the last page?
I think so, since it works for the first page. I need to include an and state defining the last page.
Something like this perhaps
@if (page < items.Count() && page != items.Count() )
Found it :)
@if (page < items.Count() && page != totalPages)
Hi, how to implemente pagination(need to show 50 dealer per page) in umbraco cms v7.7 please provide step by setp process because i was new to this cms
Thank you
I need to remove existing one and add pagination of 50 dealers per page
which pages are need to change also give me some knowledge
is working on a reply...