I am trying to write a Partial View in Umbraco 7.1 to render a box element (has a doctype, a node and properties) but I am running into problems when trying to render my Image which is filled in on the box through a Media Picker.
I can't really access it even though I tried different techniques I found in different posts around and about.
Any help would be appreciated.
This is what I have so far:
@using Newtonsoft.Json @model IPublishedContent @{ UmbracoHelper _helper = new UmbracoHelper(UmbracoContext.Current); dynamic bottomLink = JsonConvert.DeserializeObject(@Model.GetPropertyValue<string>("link")); var imgID = @Model.GetPropertyValue("grafik"); var img = ""; } <div class="box box-spot"> @imgID
</div>
@imgID returns an ID if I just write it out but when I try to use it, it looks like "imgID" is actually an obj which I can't really just convert to a string or int.
Well, I am fairly new to Umbraco 7 and I was missing a Url Picker functionality. But then I found "Multi Url Picker" made by Rasmus John which I started using.
Aside from having to manually add a "ng-app" in the angularjs code since without it, it failed, it works just fine... Now I am not sure if that's a change really worth mentioning since as said, I am new to Umbraco 7 so I am not convinced yet as to why it was missing.. Luckily I am not that new to angular :). Anyway, as you can see in the code, the expected output is JSON and that in return gets rendered on the page. I think it's a really nice and nifty package.
If I would have had enough points, I would have given the package a vote ;).
Yes, I suppose you're right. The related links editor is very similar to this package. It seems though as if you can't choose Media items with it? I may be wrong though. I will check it out.
And many thanks for the links..those should help me get started :-).
Yes you are right the core related links editor doesn't currently allow the selection of media and also you can't currently reorder the items.
It would be nice if the multi url picker shipped with a converter so you didn't have deserialize the JSON every time you used it, I will have a look and see if it's up for contribution :-)
Get Media item when @model is in use
Hi,
I am trying to write a Partial View in Umbraco 7.1 to render a box element (has a doctype, a node and properties) but I am running into problems when trying to render my Image which is filled in on the box through a Media Picker.
I can't really access it even though I tried different techniques I found in different posts around and about.
Any help would be appreciated.
This is what I have so far:
@imgID returns an ID if I just write it out but when I try to use it, it looks like "imgID" is actually an obj which I can't really just convert to a string or int.
Thanks.
Iulia
Hi Lulia,
For the image you should be doing it like this:
But what property editor is your data type using for you "link" property?
Jeavon
Thanks, Jeavon!
That really helps!
Well, I am fairly new to Umbraco 7 and I was missing a Url Picker functionality. But then I found "Multi Url Picker" made by Rasmus John which I started using.
Aside from having to manually add a "ng-app" in the angularjs code since without it, it failed, it works just fine... Now I am not sure if that's a change really worth mentioning since as said, I am new to Umbraco 7 so I am not convinced yet as to why it was missing.. Luckily I am not that new to angular :). Anyway, as you can see in the code, the expected output is JSON and that in return gets rendered on the page. I think it's a really nice and nifty package.
If I would have had enough points, I would have given the package a vote ;).
Iulia
Hi Lulia
Great, I hadn't even heard of that package! It seems a bit similar to the built in related links editor though.
For your reference all of the MVC documentation is located here and the specific section about strongly typed partial views (like you have) is here
Jeavon
Hi Jeavon,
Yes, I suppose you're right. The related links editor is very similar to this package. It seems though as if you can't choose Media items with it? I may be wrong though. I will check it out.
And many thanks for the links..those should help me get started :-).
Kind regards,
Iulia
Hi Lulia,
Yes you are right the core related links editor doesn't currently allow the selection of media and also you can't currently reorder the items.
It would be nice if the multi url picker shipped with a converter so you didn't have deserialize the JSON every time you used it, I will have a look and see if it's up for contribution :-)
Jeavon
is working on a reply...