I've installed the uBlogsy 2.0 Beta on one of my developmentsites. The Content-tree looks like this:
Home\ \Page1 \Page2 \Blog (<-uBlogsy Landingpage)
I'd like to list the latest blogposts on my root home page (Home\) and I tried to add the BlogList-macro included in the package on the masterpage for that page but it doesn't show any posts. Do I need to point out my uBlogsy-node somehow or customize the macro-script in order to use it like this?
I tried your fix but I get this error when trying to save the script-file:
error CS1061: 'umbraco.MacroEngines.DynamicNode' does not contain a definition for 'NodeTypAlias' and no extension method 'NodeTypAlias' accepting a first argument of type 'umbraco.MacroEngines.DynamicNode' could be found (are you missing a using directive or an assembly reference?)
List blogposts on site homepage
Hi,
I've installed the uBlogsy 2.0 Beta on one of my developmentsites. The Content-tree looks like this:
Home\
\Page1
\Page2
\Blog (<-uBlogsy Landingpage)
I'd like to list the latest blogposts on my root home page (Home\) and I tried to add the BlogList-macro included in the package on the masterpage for that page but it doesn't show any posts. Do I need to point out my uBlogsy-node somehow or customize the macro-script in order to use it like this?
Best regards,
Magnus
The script assumes that it is being run from a page which is under the blog landing node.
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);
Thanks Anthony for the quick reply!
I tried your fix but I get this error when trying to save the script-file:
error CS1061: 'umbraco.MacroEngines.DynamicNode' does not contain a definition for 'NodeTypAlias' and no extension method 'NodeTypAlias' accepting a first argument of type 'umbraco.MacroEngines.DynamicNode' could be found (are you missing a using directive or an assembly reference?)
Typo. Should be :
NodeTypeAlias
Thanks again! :)
Should have seen that one myself.
//Magnus
I have the same problem,
but I'm using uBlogsy 1.3.6.1.
I tried to solve it changing the uBlogsyListPosts.cshtml script with the above solution:
var landingId = new DynamicNode(Model.Id).GetChildrenAsList.Items.Where(x => x.NodeTypeAlias == "uBlogsyLanding").Single();
IEnumerable<DynamicNode> postList = uBlogsy.Web.Helpers.NodeHelper.GetPosts(landingId);
But this does not work, when saving the script I get the errormessage:
The best overloaded method match for 'uBlogsy.Web.Helpers.NodeHelper.GetPosts(int)' has some invalid arguments
Anyone any suggestions?
Thanks for your help,
Anthony
Hey Anthony
var landingId = new DynamicNode(Model.Id).GetChildrenAsList.Items.Where(x => x.NodeTypeAlias == "uBlogsyLanding").Single();
returns the landing node, not the id of the landing node.
Change the name of the variable to landing.
Then in the next line you should have GetPosts(landing.Id)
Hi Anthony,
I tried this:
var landing = new DynamicNode(Model.Id).GetChildrenAsList.Items.Where(x => x.NodeTypeAlias == "uBlogsyLanding").Single();
IEnumerable<DynamicNode> postList = uBlogsy.Web.Helpers.NodeHelper.GetPosts(landing.Id);
But when I render the page I get this error:
Error loading Razor Script uBlogsyListPosts.cshtml
Sequence contains no elements
Hi Anthony
In one of your other posts you had the landing node as a sibling of your home node... is this what you're still dealing with?
If so, you need to get the parent of the home node, then children
So like this:
var landing = new DynamicNode(Model.Id).Parent.GetChildrenAsList.Items.Where(x => x.NodeTypeAlias == "uBlogsyLanding").Single();
This is assuming Model is always going to be your home node.
Yes, that solved the problem!
My Landing node was indeed a sibling of my home node:
Thanks for your help, uBlogsy is not only a great Blog package, it is also great to use for news functionality on a website.
is working on a reply...