UBlogsy - Adding post listing to home page (parent node)
Hi guys,
I am currently setting up a website and as part of that site I have implemented Ublogsy as a child node E.g.
Home/
/About
/Products
/Blog
I am attempting to include a short list of the latest posts within the home page of teh website from the Blog and have previously used the following code (see below) but for some reason this code is no longer working. For reference 'UBlogsyHomeShowPost.cshtml' is also a set of code I have previously used and does exist in this set up.... any idea guys!?
Here's the code...Cheers guys!
@using System.Linq
@using System.Xml.Linq
@using umbraco.MacroEngines
@using uBlogsy.Common.Extensions
@using uBlogsy.Common.Helpers
@using uBlogsy.BusinessLogic
@{
const int ITEMS_PER_PAGE = 20; // for testing
// get item count
int count = int.Parse(@Parameter.ItemCount);
IEnumerable<DynamicNode> nodes;
if (@Parameter.Small == "1")
{
var landing = new DynamicNode(Model.Id).Parent.GetChildrenAsList.Items.Where(x => x.NodeTypeAlias == "uBlogsyLanding").Single();
var posts = PostService.Instance.GetPosts(landing.Id);
UBlogsy - Adding post listing to home page (parent node)
Hi guys,
I am currently setting up a website and as part of that site I have implemented Ublogsy as a child node E.g.
Home/
/About
/Products
/Blog
I am attempting to include a short list of the latest posts within the home page of teh website from the Blog and have previously used the following code (see below) but for some reason this code is no longer working. For reference 'UBlogsyHomeShowPost.cshtml' is also a set of code I have previously used and does exist in this set up.... any idea guys!?
Here's the code...Cheers guys!
@using System.Linq
@using System.Xml.Linq
@using umbraco.MacroEngines
@using uBlogsy.Common.Extensions
@using uBlogsy.Common.Helpers
@using uBlogsy.BusinessLogic
@{
const int ITEMS_PER_PAGE = 20; // for testing
// get item count
int count = int.Parse(@Parameter.ItemCount);
IEnumerable<DynamicNode> nodes;
if (@Parameter.Small == "1")
{
var landing = new DynamicNode(Model.Id).Parent.GetChildrenAsList.Items.Where(x => x.NodeTypeAlias == "uBlogsyLanding").Single();
var posts = PostService.Instance.GetPosts(landing.Id);
nodes = ((IEnumerable<DynamicNode>)posts).Take(count);
<div class="uBlogsy_posts_container uBlogsy_bottom_border">
<h2>@Dictionary["uBlogsyDicPostsLatest"]</h2>
<ul>
@foreach (DynamicNode n in nodes)
{
<li>
<a href="@n.Url" title="@n.GetProperty("uBlogsyContentTitle").Value">
<span>@n.GetProperty("uBlogsyContentTitle").Value</span>
</a>
</li>
}
</ul>
</div>
}
else
{
// get tag, category, or author from query string
var tag = Request.QueryString["tag"];
var category = Request.QueryString["category"];
var author = Request.QueryString["author"];
var searchTerm = Request.QueryString["search"];
var commenter = Request.QueryString["commenter"];
int page = int.TryParse(Request.QueryString["page"], out page) ? page : 1;
IEnumerable<DynamicNode> posts = PostService.Instance.GetPosts(Model.Id, tag, category, author, searchTerm, commenter, page - 1, count);
// get landing node
var landing = DataService.Instance.GetLanding(Model.Id);
// only get posts where the path has the landing node's id.
posts = posts.Where(x => x.Path.Contains(landing.Id + ","));
nodes = posts.Take(count).ToList();
int postCount = PostService.Instance.GetPosts(Model.Id, tag, category, author, searchTerm, commenter, 0, int.MaxValue).Count;
// pagination
@RenderPagination(page, postCount, count)
// render search result count when this script is displaying search results
if (!string.IsNullOrEmpty(searchTerm))
{
<script type="text/javascript">
$(document).ready(function () {
$('.uBlogsy_content_body').hide();
});
</script>
<h3>@nodes.Count() Results: </h3>
}
// show each post
foreach (DynamicNode n in nodes)
{
@RenderPage("/macroScripts/uBlogsy/uBlogsyHomeShowPost.cshtml", n.Id)
}
}
}
@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;
}
is working on a reply...