Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have some problem on my blog page with regards to paging.. it seems that I can't use my own property "blogSubheader"
var pageSize = 5; if (Model.Content.HasValue("numberOfItemsPerPge")) { pageSize = Model.Content.GetPropertyValue<int>("numberOfItemsPerPage"); } var page = 1; int.TryParse(Request.QueryString["page"], 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 > totalPages) { page = totalPages; } else if (page < 1) { page = 1; }
this is what i loop out in my foreach:
@foreach (var blogPost in items.Skip((page - 1) * pageSize).Take(pageSize).OrderBy(x => x.CreateDate)) { <!--Article--> <article class="post-preview"> <a href="@blogPost.Url"> <h2 class="post-title">@blogPost.Name</h2> <h3 class="post-subtitle">@blogPost.blogSubheader</h3> </a> <p class="post-meta"> Posted by <a href="@blogPost.Url">@Model.Content.CreatorName</a> on @DateTime.Today.ToString("MMMM d, yyyy") </p> </article> <hr /> }
When I type "blogSubheader" it shows it as an error... And on my blogPost documentype I have the property.
Hope my question was understandable - thanks in advance!
Comment author was deleted
Hey,
The type of objects you are working with isn't dynamic so you'll have to fetch the property in a longer syntax like you do here
pageSize = Model.Content.GetPropertyValue<int>("numberOfItemsPerPage");
so try
@blogPost.GetPropertyValue<string>("blogSubheader")
When I use it
<h3 class="post-subtitle">@blogPost.GetPropertyValue<string>("blogSubheader")</h3>
it gives me an error:
Error: Cannot convert method group 'GetPropertyValue' to non-delegate type 'object'. Did you intend to invoke the method?
@blogPost.GetPropertyValue("blogSubheader")
I used this one without the <'string'> and it worked perfectly!
Thanks mate!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Paging in Umbraco 7
I have some problem on my blog page with regards to paging.. it seems that I can't use my own property "blogSubheader"
this is what i loop out in my foreach:
When I type "blogSubheader" it shows it as an error... And on my blogPost documentype I have the property.
Hope my question was understandable - thanks in advance!
Comment author was deleted
Hey,
The type of objects you are working with isn't dynamic so you'll have to fetch the property in a longer syntax like you do here
so try
When I use it
it gives me an error:
Error: Cannot convert method group 'GetPropertyValue' to non-delegate type 'object'. Did you intend to invoke the method?
I used this one without the <'string'> and it worked perfectly!
Thanks mate!
is working on a reply...