But there are no uBlogsy posts appearing on my homepage:
I don't know why there are no posts because I implemented this the same way on an other website (www.webmove.be) where it's working perfectly. The only difference with this other website is that on the not working website, the Blog node is not a child node of the home node:
Could this be the problem?
Does anyone has other suggestions why the posts aren't rendering on the homepage?
The reason why I didn't see the latest posts on my homepage was because it was not a child of the landingpage node. I fixed this by using this code in the uBlogsyListPosts.cshtml file:
var landing = new DynamicNode(Model.Id).Parent.GetChildrenAsList.Items.Where(x => x.NodeTypeAlias == "uBlogsyLanding").Single();
When I do this, the homepage brings up an error through firebug : Error loading Razor Script uBlogsyListPosts.cshtml Object reference not set to an instance of an object.
My current cshtml file looks like this: @{ // get all posts IEnumerable<DynamicNode> postList = uBlogsy.Web.Helpers.NodeHelper.GetPosts(Model.Id); var landing = new DynamicNode(Model.Id).Parent.GetChildrenAsList.Items.Where(x => x.NodeTypeAlias == "uBlogsyLanding").Single(); // get item count int count = int.Parse(@Parameter.ItemCount);
IEnumerable<DynamicNode> nodes;
if (@Parameter.Small == "1") { nodes = postList.Take(count); <div class="uBlogsy_posts_container uBlogsy_bottom_border"> <h2> Latest posts</h2> <ul> @foreach (DynamicNode n in nodes) { <li> <a href="@n.Url"> <span>@n.GetProperty("uBlogsyContentTitle").Value</span> </a> @* - <span>@n.GetProperty("uBlogsyPostDate").Value.FormatDateTimeOrdinal("d MMMM yyyy")</span>*@ </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"];
Thanks for your reply. I am using the same version.
Sorry to be thick, but by hardcoded landing id do you mean the ID number which is under the properties tab of the destination page, e.g my social wallop bit?
such as this : IEnumerable<DynamicNode> postList = uBlogsy.Web.Helpers.NodeHelper.GetPosts(1048);?
Sorry don't mean to seem stupid, just been confused by it.
Thanks a lot Anthony. This now displays in a bulleted list. Glad they're on the homepage at last!
Is it possible, rather than pulling through just the title as a link to the main article, to display the title and then underneath that say the first couple of lines of the post?
Such as this:
Even if it just pulled the title and say, the first 140 characters of the post?
I was able to make the script a bit more flexible by going to the macro and adding a parameter for "BlogNode" as a ContentPicker
Then, when you add the macro to the screen you pick the landing page of the blog you wish to get posts for.
Inside the script you can then do the following:
// get all posts DynamicNode mynode = new DynamicNode(@Parameter.BlogNode); IEnumerable<DynamicNode> postList = uBlogsy.Web.Helpers.NodeHelper.GetPosts(mynode .Id);
It took me forever to figure out I had to load the node as a DynamicNode rather than just feeding GetPosts a node ID. Maybe this will help some of you...
but am getting the error "error CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'uBlogsy.Web' (are you missing an assembly reference?)"
I am using uBlogsy 2.0.0.1. Have the Helpers changed since the last post?
I'm having the exact same issue with my Umbraco setup. I have a List Categories macro that I'd like to appear on the home page.
I figured it should be easy to hardcode the page Id into the GetPosts method of the macro but it is failing.
DynamicNode blogBaseNode = new DynamicNode(1194); var nodes = PostService.Instance.GetPosts(blogBaseNode.Id); foreach (var n in nodes) { allCategories.AddRange(n.uBlogsyPostCategories.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)); }
Following the tip above, I instantiated a new DynamicNode and used it to GetPosts. However, this code fails when calling n.uBlogsyPostCategories.
The original code was:
var nodes = PostService.Instance.GetPosts(Model.Id); foreach (var n in nodes) { allCategories.AddRange(n.uBlogsyPostCategories.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)); }
That worked! Thanks for being so responsive. I've been banging my head on this for a day and a half after realizing the uBlogsy package that is installed through umbraco is not the latest version and will not work with my version of umbraco.
I faced with a similar problem - can't place blog posts on the homepage. I get this error - Error loading MacroEngine script (file: /uBlogsy/uBlogsyListPosts.cshtml). I tried to edit uBlogsyListPosts.cshtml according to your recommendations. I see this line - var landing = DataService.Instance.GetLanding(Model.Id); and tried to replece it like Anthony described but get the same error, and on the blog self homepage too. I use letest version of uBlogsy - 2.1.1.1. Is there a way to get blog posts on homepage in this version?
where 1114 is the ID for the blog's homepage. I'm sure I'm pasting the code in the wrong place so could someone please tell me exactly what and where i should edit?
Managed to post titles displaying on the homepage using the following suggestion from AnthonyDang (see this thread):
Where you have this:
var posts = PostService.Instance.GetPosts(Model.Id);
Change to:
var landingId = new DynamicNode(Model.Id).GetChildrenAsList.Items.Where(x => x.NodeTypAlias == "uBlogsyLanding").Single();
var posts = PostService.Instance.GetPosts(landingId);
How can I get the post descriptions to display? I know someone earlier in this thread was trying to do the same.
I tried this and was able to get both the Small=1 scenario, and the full blog roll to work on my homepage. My setup is probably identical to yours. Keep in mind:
Hard code your landing ID EVERYWHERE you see "Model.Id"
If you created a new macro, make sure you actually added the parameters <-- I'm guessing this is one of your problems
any reference to "Model" will now be referencing your Home page (or wherever you are calling this) so you must remove things like
no uBlogsy posts on homepage
Hi,
I want to have the latest 5 uBlogsy posts appear on my homepage. For that I implemented the uBlogsyListPosts.cshtml script on my Home template:
<umbraco:Macro ItemCount="5" Small="1" Alias="uBlogsyListPosts" runat="server"></umbraco:Macro>
But there are no uBlogsy posts appearing on my homepage:
I don't know why there are no posts because I implemented this the same way on an other website (www.webmove.be) where it's working perfectly. The only difference with this other website is that on the not working website, the Blog node is not a child node of the home node:
Could this be the problem?
Does anyone has other suggestions why the posts aren't rendering on the homepage?
Thanks for your help,
Anthony
The cshtml file looks for the landing node going up the tree from the current node.
In your case, your home node is a sibling of the landing node.
I would either hardcode the id of the landing node, or do a search for it.
This is my content tree: I am having the issue also of it just saying "Latest Posts", something I have to do other than link macro on homepage?
Easiest fix is to hardcode the landing node id in the macro script.
Hi Pat,
The reason why I didn't see the latest posts on my homepage was because it was not a child of the landingpage node. I fixed this by using this code in the uBlogsyListPosts.cshtml file:
var landing = new DynamicNode(Model.Id).Parent.GetChildrenAsList.Items.Where(x => x.NodeTypeAlias == "uBlogsyLanding").Single();
Hope this helps,
Anthony
Hi,
When I do this, the homepage brings up an error through firebug : Error loading Razor Script uBlogsyListPosts.cshtml Object reference not set to an instance of an object.
My current cshtml file looks like this:
@{
// get all posts
IEnumerable<DynamicNode> postList = uBlogsy.Web.Helpers.NodeHelper.GetPosts(Model.Id);
var landing = new DynamicNode(Model.Id).Parent.GetChildrenAsList.Items.Where(x => x.NodeTypeAlias == "uBlogsyLanding").Single();
// get item count
int count = int.Parse(@Parameter.ItemCount);
IEnumerable<DynamicNode> nodes;
if (@Parameter.Small == "1")
{
nodes = postList.Take(count);
<div class="uBlogsy_posts_container uBlogsy_bottom_border">
<h2>
Latest posts</h2>
<ul>
@foreach (DynamicNode n in nodes)
{
<li>
<a href="@n.Url">
<span>@n.GetProperty("uBlogsyContentTitle").Value</span>
</a>
@* - <span>@n.GetProperty("uBlogsyPostDate").Value.FormatDateTimeOrdinal("d MMMM yyyy")</span>*@
</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"];
nodes = NodeHelper.GetPosts(tag, category, author, searchTerm, postList).Take(count).ToList();
if (!string.IsNullOrEmpty(searchTerm))
{
<script type="text/javascript">
$(document).ready(function () {
$('.uBlogsy_content_body').hide();
});
</script>
<h3>@nodes.Count() Results: </h3>
}
foreach (DynamicNode n in nodes)
{
@RenderPage("/macroScripts/uBlogsyShowPost.cshtml", n.Id)
}
}
}
Apologies for layout, cant think how to make it look like code rather than plain text
Hi Pat,
you should add this after 'var landing ...'
IEnumerable<DynamicNode> postList = uBlogsy.Web.Helpers.NodeHelper.GetPosts(landing.Id);
Have tried that as well, still same error coming up, strange.
Pat,
To get this straight, the node that should read out the latest post is the 'Social Wallop' node?
Yes, that node is the home page, AboutUs is the 2nd page but the blog posts should appear on the SW Node, yes.
Maybe it's your version of uBlogsy. I'm using version 1.3.6.1
Otherwise you can, like Anthony is saying, hard code your landing node:
IEnumerable<DynamicNode> postList = uBlogsy.Web.Helpers.NodeHelper.GetPosts(hardcoded landingnode id);
Thanks for your reply. I am using the same version.
Sorry to be thick, but by hardcoded landing id do you mean the ID number which is under the properties tab of the destination page, e.g my social wallop bit?
such as this : IEnumerable<DynamicNode> postList = uBlogsy.Web.Helpers.NodeHelper.GetPosts(1048);?
Sorry don't mean to seem stupid, just been confused by it.
Hi Pat,
Indeed, it's the Id property (under 'properties' tab) of your landing node page (in your case the 'My Blog' page)
Thanks a lot Anthony. This now displays in a bulleted list. Glad they're on the homepage at last!
Is it possible, rather than pulling through just the title as a link to the main article, to display the title and then underneath that say the first couple of lines of the post?
Such as this:
Even if it just pulled the title and say, the first 140 characters of the post?
Hi Pat,
You can just list a part of your body text using the Library.Truncate function.
For example this is the way I show the first 300 characters of the body text:
@(Library.Truncate(Library.StripHtml(body), 300, true))
hope this helps,
Anthony
I was able to make the script a bit more flexible by going to the macro and adding a parameter for "BlogNode" as a ContentPicker
Then, when you add the macro to the screen you pick the landing page of the blog you wish to get posts for.
Inside the script you can then do the following:
// get all posts
DynamicNode mynode = new DynamicNode(@Parameter.BlogNode);
IEnumerable<DynamicNode> postList = uBlogsy.Web.Helpers.NodeHelper.GetPosts(mynode .Id);
It took me forever to figure out I had to load the node as a DynamicNode rather than just feeding GetPosts a node ID. Maybe this will help some of you...
Hi,
I've been trying to hardcode the landing node IDs to list latest posts for 3 blogs on various pages (on same site) using uBlogsy using....
IEnumerable<DynamicNode> postList = uBlogsy.Web.Helpers.NodeHelper.GetPosts(hardcoded landingnode id);
but am getting the error "error CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'uBlogsy.Web' (are you missing an assembly reference?)"
I am using uBlogsy 2.0.0.1. Have the Helpers changed since the last post?
Thanks
Replace
uBlogsy.Web.Helpers.NodeHelper
with
PostService.Instance
I'm having the exact same issue with my Umbraco setup. I have a List Categories macro that I'd like to appear on the home page.
I figured it should be easy to hardcode the page Id into the GetPosts method of the macro but it is failing.
DynamicNode blogBaseNode = new DynamicNode(1194);
var nodes = PostService.Instance.GetPosts(blogBaseNode.Id);
foreach (var n in nodes)
{
allCategories.AddRange(n.uBlogsyPostCategories.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
}
Following the tip above, I instantiated a new DynamicNode and used it to GetPosts. However, this code fails when calling n.uBlogsyPostCategories.
The original code was:
var nodes = PostService.Instance.GetPosts(Model.Id);
foreach (var n in nodes)
{
allCategories.AddRange(n.uBlogsyPostCategories.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
}
try this:
foreach (var n in nodes)
{
allCategories.AddRange(n.GetPropertyValue("uBlogsyPostCategories").Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
}
That worked! Thanks for being so responsive. I've been banging my head on this for a day and a half after realizing the uBlogsy package that is installed through umbraco is not the latest version and will not work with my version of umbraco.
Hi,
I faced with a similar problem - can't place blog posts on the homepage. I get this error - Error loading MacroEngine script (file: /uBlogsy/uBlogsyListPosts.cshtml). I tried to edit uBlogsyListPosts.cshtml according to your recommendations. I see this line - var landing = DataService.Instance.GetLanding(Model.Id); and tried to replece it like Anthony described but get the same error, and on the blog self homepage too. I use letest version of uBlogsy - 2.1.1.1. Is there a way to get blog posts on homepage in this version?
Thanks!
siriosus can you paste your code and a snap of your content tree
I am having the same problem as siriousus. I've installed uBlogsy 2.1.1.0 and the site is structured...
Home
> About
> Contact
> Blog
The uBlogsyListPosts.cshtml code is as follows:
I've tried replacing...
DataService.Instance.GetLanding(Model.Id);
with...
IEnumerable<DynamicNode> postList = PostService.Instance.GetPosts(1114);
where 1114 is the ID for the blog's homepage. I'm sure I'm pasting the code in the wrong place so could someone please tell me exactly what and where i should edit?
Many thanks!
Managed to post titles displaying on the homepage using the following suggestion from AnthonyDang (see this thread):
Where you have this:
Change to:
How can I get the post descriptions to display? I know someone earlier in this thread was trying to do the same.
Thanks
I think I need to update the following code in the uBlogsyShowPost.cshtml but have no idea how...
Can anyone help?
Many thanks!
I tried this and was able to get both the Small=1 scenario, and the full blog roll to work on my homepage. My setup is probably identical to yours. Keep in mind:
because Model.NoteTypeAlias will NOT be "uBlogsyLanding"
is working on a reply...