@{ // 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);
@{ 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?
Would I use the same @inherit statement at the top of a Global Helper when I'm getting the same "The type or namespace name 'Media' does not exist in the namespace 'Umbraco'" error? For example, in App_Code/GlobalHelpers.cshtml, I created this helper which works fine when it's in a Partial View, but not when I put it into the global helper:
@helper GetCropUrl(dynamic imageName, string cropName ){
@* get crop URL name from image and crop name *@
var image = Umbraco.Media(imageName); @* this is the line causing the error *@
var imglink = image.url;
var imgcrop = image.croppedImage;
if (imgcrop.ToString() != "")
{
if (imgcrop.Find("@name", cropName).BaseElement.ToString() != "")
{
imglink = imgcrop.Find("@name", cropName).url;
}
}
@imglink
}*@
Calling Umbraco.Media from a nested Partial
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
And then in my slideshow.chtml partial:
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
By the way I'm using Umbraco 6.1.2 in Mvc Mode
I think using @inherits rather than @model on your nested partial should work, like this:
You'll then have access to the @Umbraco helper.
Andy
@Andy Thankyou Thankyou Thankyou!
worked! hopefully anyone else out there having trouble with find this post :)
Would I use the same @inherit statement at the top of a Global Helper when I'm getting the same "The type or namespace name 'Media' does not exist in the namespace 'Umbraco'" error? For example, in App_Code/GlobalHelpers.cshtml, I created this helper which works fine when it's in a Partial View, but not when I put it into the global helper:
Hi Eric,
You can use a custom static variable in your helper. Here's how I sort it out.
is working on a reply...