Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Magnus Jonsson 33 posts 53 karma points
    Dec 15, 2011 @ 15:36
    Magnus Jonsson
    0

    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

     

     

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Dec 15, 2011 @ 15:48
    Anthony Dang
    0

    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);

     

  • Magnus Jonsson 33 posts 53 karma points
    Dec 15, 2011 @ 15:58
    Magnus Jonsson
    0

    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?)

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Dec 15, 2011 @ 16:41
    Anthony Dang
    0

    Typo. Should be : 

    NodeTypeAlias

     

  • Magnus Jonsson 33 posts 53 karma points
    Dec 15, 2011 @ 22:32
    Magnus Jonsson
    0

    Thanks again! :)

    Should have seen that one myself. 

    //Magnus

  • Anthony Candaele 1197 posts 2049 karma points
    Dec 31, 2011 @ 13:27
    Anthony Candaele
    0

    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.NodeTypeAlias == "uBlogsyLanding").Single();
    IEnumerable<DynamicNodepostList 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

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Jan 03, 2012 @ 11:17
    Anthony Dang
    1

    Hey Anthony

    var landingId new DynamicNode(Model.Id).GetChildrenAsList.Items.Where(=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)

     

  • Anthony Candaele 1197 posts 2049 karma points
    Jan 03, 2012 @ 12:37
    Anthony Candaele
    0

    Hi Anthony,

    I tried this:

    var landing new DynamicNode(Model.Id).GetChildrenAsList.Items.Where(=x.NodeTypeAlias == "uBlogsyLanding").Single();
    IEnumerable<DynamicNodepostList 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

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Jan 03, 2012 @ 12:46
    Anthony Dang
    1

    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.NodeTypeAlias == "uBlogsyLanding").Single();

     

    This is assuming Model is always going to be your home node.

     

     

  • Anthony Candaele 1197 posts 2049 karma points
    Jan 03, 2012 @ 12:58
    Anthony Candaele
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft