Copied to clipboard

Flag this post as spam?

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


  • denisedelbando 141 posts 339 karma points
    Dec 10, 2013 @ 17:53
    denisedelbando
    0

    Error on ToIPublishedContent(true)


    Hello all, 

    there is something wrong with my razor script. instead of using the built in ublogsy partial views, i want to create my own. Long story short, i already created the widget for the site before i decided to use ublogsy.

    Anyway in my macro razor script, i am trying to copy the code to show latest 3 posts. I have a problem with the the IPublishContent because @Model doesnt have the same data type. After a lot of diggin i saw this code

    UmbracoHelper _helper = new UmbracoHelper(UmbracoContext.Current);

    var newModel = _helper.TypedContent(blogParentNode.Id);

     

    newModel becomes an IPublishContent instance. 

     

    And when i get to:

    PostService.Instance.GetPosts(newModel).Take(3).ToIPublishedContent(true);

     

    I get an error during ToIPublishedContent the razor script throws an error. I tried getting rid of it and it works fine. Am i missing any reference? Here are my imports:

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @using umbraco.MacroEngines

    @using Umbraco.Web

    @using System.Linq

    @using uBlogsy.BusinessLogic

    @using uHelpsy.Extensions

     

    @using Umbraco.Core.Models

     

    Anyway, I'm almost there. I just need help on why it doesn't work on that part. 


    Thank you very much.


     


     

     

  • denisedelbando 141 posts 339 karma points
    Dec 10, 2013 @ 18:13
    denisedelbando
    0

    Everytime I ask for help, few minutes later i figure it out.

    Instead of using that method, I had to just go through the loop and convert every Examine.SearchResult to IPublishedContent:

    foreach(var item in nodes){

    IPublishedContent n = IPublishedContentHelper.GetNode(item.Id);

    //properties here

     

    }

  • denisedelbando 141 posts 339 karma points
    Dec 10, 2013 @ 18:14
    denisedelbando
    0

    Complete import. I dont even know if i used all these

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @using umbraco.MacroEngines

    @using Umbraco.Web

    @using System.Linq

    @using uBlogsy.BusinessLogic

    @using uHelpsy.Extensions

    @using uHelpsy.Helpers

    @using Umbraco.Core.Models

     

    @using Examine

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Dec 16, 2013 @ 18:17
    Anthony Dang
    0

    You also have to make sure that you're either in mvc or webforms mode.

    DynamicNodeContext is for webforms mode

     

     

Please Sign in or register to post replies

Write your reply to:

Draft