I'm having a problem with using Umbraco.Media from a nested partial (partial within a partial)
similar to this example: http://our.umbraco.org/Documentation/Reference/Mvc/partial-views
my code goes something like
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
// Main Content getting a value from a content picker
var content = Model.Content.GetPropertyValue("mainContent").ToString();
string[] nodeIds = content.Split(',');
//looping through my nodes
foreach (var node in nodeIds)
{
var realNode = Umbraco.TypedContent(node);
if(realNode.HasProperty("bodyText")){
//render bodytext etc
}else if(realNode.HasProperty("slideShowImages")){
//render slideshow
@Html.Partial("slideshow", realNode)
}
}
}
And then in my slideshow.chtml partial:
@model IPublishedContent
@{
var Slideshow = Model.GetPropertyValue("slideshowImages").ToString();
string[] nodes = Slideshow.Split(',');
foreach(var nodeId in nodes){
var media = Umbraco.Media(nodeId);
var defaultClass = "class=\"default\"";
<img src="@media.url" />
}
But this gives me the error:
The type or namespace name 'Media' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?
How do I re-reference the correct Namespace so that Umbraco.Media works within my nested partial?
I've tried @using Umbraco, Umbraco.Web, Umbraco.Web.Media
is it possible to use Umbraco.Media at the nested level or should I give up?
thanks!
- Tim
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/42832-calling-umbracomedia-from-a-nested-partial