Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
In Views I normally get my properties values like this:
E.g.
var myProperty = Umbraco.Content(3354).GetPropertyValue<ArchetypeModel>("myPropertyAlias"); foreach(var item in myProperty) { <div>@item.GetValue("itemAlias")</div> }
But how can I get my property values inside a utitilty class?
Dan
I think that might be a job for the Umbraco helper
var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
Then you should be able to get access to properties as usual
var myProperty = umbracoHelper.Content(3354).GetPropertyValue<ArchetypeModel>("myPropertyAlias");
Thanks Julio, works great!
In my property I have an Media Picker data type, so I need to get the image url. Normally I would do:
var img = Umbraco.TypedMedia(item.GetValue("icon")); <img src="@img.Url" />
How can I get TypedMedia in my class?
Thanks,
Got this working using same "umbracoHelper":
var image = umbracoHelper.TypedMedia(item.GetValue("icon"));
Thanks!
I was going to suggest exactly the same
Glad you got it working
J
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get property values in utility class
Hi,
In Views I normally get my properties values like this:
E.g.
But how can I get my property values inside a utitilty class?
Dan
I think that might be a job for the Umbraco helper
Then you should be able to get access to properties as usual
Thanks Julio, works great!
In my property I have an Media Picker data type, so I need to get the image url. Normally I would do:
How can I get TypedMedia in my class?
Thanks,
Dan
Got this working using same "umbracoHelper":
Thanks!
Dan
I was going to suggest exactly the same
Glad you got it working
J
is working on a reply...