partial view macro inheritance issue - what am I doing wrong??? :(
I have the following code in a Partial View Macro file (HeroCarousel.cshtml).
@*inherits Umbraco.Web.Macros.PartialViewMacroPage*@
@inherits umbraco.MacroEngines.DynamicNodeContext
@using The_Drum.App_Code
@{
if(Utilities.getXMLNode("HeroCarouselFolderID") != null)
{
//Get the id of the carousel images folder
var carouselFolderID = Utilities.getXMLNode("HeroCarouselFolderID");
//Get the media folder as a dynamic node
var mediaFolder = Library.MediaById(carouselFolderID);
if (mediaFolder.Children.Any())
{
//for each item in children of the selected media folder
foreach (var mediaItem in mediaFolder.Children)
{
<a href="#!" class="img"><img src="@mediaItem.umbracoFile" alt="@mediaItem.Name"/></a>
}
}
}
}
I think this is because the file needs to inherit from "Umbraco.Web.Macros.PartialViewMacroPage", but I need the methods and properties from "inherits umbraco.MacroEngines.DynamicNodeContext" - HOW DO I FIX THIS PLEASE?
partial view macro inheritance issue - what am I doing wrong??? :(
I have the following code in a Partial View Macro file (HeroCarousel.cshtml).
When I try and use in my template like so
it errors:
I think this is because the file needs to inherit from "Umbraco.Web.Macros.PartialViewMacroPage", but I need the methods and properties from "inherits umbraco.MacroEngines.DynamicNodeContext" - HOW DO I FIX THIS PLEASE?
I'm no pro, but have you tried
@using umbraco.MacroEngines.DynamicNodeContext
?Hi what do you need from dynamic node context? Can you not just instance a new dynamic node passing in the context id?
Charlie :).
If you remove all the code from your partial view. Does it load correctly? Charlie :)
is working on a reply...