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
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.
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.
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
}
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
You also have to make sure that you're either in mvc or webforms mode.
DynamicNodeContext is for webforms mode
is working on a reply...