as i understand it, @Model will return static, as you call dynamic you may need to exchange your @Model for @CurrentPage to return the dynamic. I think this is what is causing your error although the error does not seem to point to it, if you get my.meaning.
Umbraco.Web.Models.RenderModel' does not contain a definition for 'NodeTypeAlias'
Getting this error with my partial view:
@inherits Umbraco.Web.Mvc.UmbracoViewPage @using umbraco.MacroEngines @helper setHeadings(string sectionHeading,string pageHeading,string contentTitle){ } @functions{ public string getSectionIcon(dynamic node){ string prefix = ""; dynamic rootNode = Model.AncestorOrSelf(); if(rootNode.HasValue("mainMenu")){ foreach(var item in rootNode.mainMenu){ var id = item.link.ToString(); if(id == node.Id.ToString()){ prefix = item.prefix.ToString() + " "; } } } return prefix; } } @helper eventHeadings(){ @setHeadings("Event Section","Event Heading","Event Title") } @helper newsHeadings(){ @setHeadings("News Section","News Heading","News Title") } @helper primaryCareHeadings(){ @setHeadings("Primary Care","PC Heading","PC Title") } @helper defaultHeadings(){ int level = Model.Level; string sectionHeading = ""; string pageHeading = ""; string contentTitle = ""; string parentLink; dynamic parent; if(Model.Level <= 2){ //Level 1 sectionHeading = getSectionIcon(Model) + Model.Title; } else { //Level 2+ dynamic sectionNode = Model.AncestorOrSelf(2); sectionHeading = getSectionIcon(sectionNode) + " " + sectionNode.Title; //sectionHeading = sectionNode.Title; } //Just show title for pages at level 2 if(level < 4) { //Level 1-3 pageHeading = Model.HasValue("subheading") ? Model.Subheading : Model.Title; } else { //Level 4+ parent = Model.Parent; //Show link to parent and then page title... pageHeading = parent.Title; contentTitle = Model.Title; } @setHeadings(sectionHeading,pageHeading,contentTitle) } @{ string nodeType = Model.NodeTypeAlias; switch (nodeType) { case "event": @eventHeadings() break; case "news": @newsHeadings() break; case "primaryCare": @primaryCareHeadings() break; default: @defaultHeadings() break; } }hi Robert
as i understand it, @Model will return static, as you call dynamic you may need to exchange your @Model for @CurrentPage to return the dynamic. I think this is what is causing your error although the error does not seem to point to it, if you get my.meaning.
hope it helps
gary
Hi Robert,
Did you find the solution for your problem,
If so can you please post the solution.
Thanks BJ
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.