It is possible for you to share the code that you have so far, then I think it is much easier for people to help you, at least point you in the right direction.
//code for displaying 3 popular post: --------------------------------------------------- @{ var count1 =1; foreach(var popular2 in CurrentPage.Descendants(4).Where("popularposts")){ if(count1<4){ <div class="media"> <a class="pull-left" href="@popular2.Url"><img class="media-object" src="@popular2.pagebgimage" width="100" alt=""></a> <div class="media-body"> <h4 class="media-heading"><a href="post-video.html">@popular2.Name</a></h4> <p class="post-date">@popular2.CreateDate</p> </div> </div> count1++;}}} </div></div>
//Here is the HTML where I want insert code for displaying next and previous links ------------------------------------------------------------------------------------- <div class="paging clearfix"> <a class="btn pull-left" href="#"><i class="icon-arrow-left2 left"></i><span>Older</span><span class="hidden-xs"> Posts</span></a> <a class="btn pull-right" href="#"><span>Newer</span><span class="hidden-xs"> Posts</span><i class="icon-arrow-right2 right"></i></a> </div>
With this could you should be able to get to the previous or next post but, it will just go directly link to the post.
//Here is the HTML where I want insert code for displaying next and previous links ------------------------------------------------------------------------------------- <div class="paging clearfix"> @if (@CurrentPage.Previous() != null){ <a class="btn pull-left" href="@CurrentPage.Previous().Url"><i class="icon-arrow-left2 left"></i><span>Older</span><span class="hidden-xs"> Posts</span></a> } @if (@CurrentPage.Next() != null){ <a class="btn pull-right" href="@CurrentPage.Next().Url"><span>Newer</span><span class="hidden-xs"> Posts</span><i class="icon-arrow-right2 right"></i></a> } </div>
Perhaps, you are more after some paging where when you click on the previuous and next you will get a page with another 3 news items.
@inheritsUmbracoTemplatePage @{Layout="MasterTemplate.cshtml";} @{ var pageSize =3; 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);
problem creating nextpost and previous post button
Hi,
I need to display 3 posts and a button for displaying next or previous post. How can this be achieved?
I am using foreach loop for displaying posts which reside inside news page post using Currentpage.Descendent(4).
Thanks
Hi pushpendu,
It is possible for you to share the code that you have so far, then I think it is much easier for people to help you, at least point you in the right direction.
Looking forward to hear from you.
/Dennis
HI Dennis,
Thanks for your reply, Yes why not.. Here the code:
Here is the screensort of what I want.
Thanks
Hi pushpendu,
With this could you should be able to get to the previous or next post but, it will just go directly link to the post.
Perhaps, you are more after some paging where when you click on the previuous and next you will get a page with another 3 news items.
If you are using the paging script remember to change it so it fit your document types and so on.
Hope this helps, or at least could be a good starting point
/Dennis
is working on a reply...