I am currently working in a template and would like to show the selected value of the xml dropdown menu from the CMS for a specific page. I already have looped through the pages to show all the properties linked to each page however the nupicker value shows the ID instead of the value.
e.g. foreach var item ....
@item.dropdownmenuitem
Please can somebosy tell me the syntax to show the value?
@item.dropdownmenuitem.Label, @item.dropdownmenuitem.Name does not work.
If your variable is rendering out as 'Umbraco.Web.Models.DynamicPublishedContent', can you append .Name or whatever property you want from that dynamic obj ?
Stephanie, I would also be interested if you were successful in this. Currently I am trying to resolve a property value contained in a nupicker inside the Orderby clause of a where statement. Failing that I'm looking for a way to generate another list that I can pre-populate and then resolve the picker values and do a sort based on that... any ideas apprecated.
Nupicker XML dropdown value, not ID
Hi all,
I am currently working in a template and would like to show the selected value of the xml dropdown menu from the CMS for a specific page. I already have looped through the pages to show all the properties linked to each page however the nupicker value shows the ID instead of the value.
e.g. foreach var item ....
@item.dropdownmenuitem
Please can somebosy tell me the syntax to show the value?
@item.dropdownmenuitem.Label, @item.dropdownmenuitem.Name does not work.
Steph
Hi Steph,
There's a built in PropertyValueConver for nuPickers, so you should be able to do the following:
Dynamic
@{ var item = CurrentPage.myNuPickerPropertyAlias.AsDynamicPublishedContent().Single(); }
Strongly Typed
@{ var item = Model.Content.GetPropertyValue<Picker>("myNuPcikerPropertyAlias").AsPublishedContent().Single(); }
HTH,
Hendy
Hi Hendy,
When I am already iterating through childpages like so
[code]@foreach (var item in childpages)
var dynamicvariable = CurrentPage.myNuPickerPropertyAlias.AsDynamicPublishedContent().Single();
@item.myproperty[/code]
Can you tell me how I would use the dynamic variable within my for each loop?
I have tried @item.@dynamicvariable but it is displayed as 'Umbraco.Web.Models.DynamicPublishedContent'
Steph
Hi Steph,
If your variable is rendering out as 'Umbraco.Web.Models.DynamicPublishedContent', can you append .Name or whatever property you want from that dynamic obj ?
Hi Hendy,
I've tried:
@dynamicvar.Name - returns nothing
@[email protected] - returns Umbraco.Web.Models.DynamicPublishedContent
@item.dynamicvar.Name - returns Umbraco.Web.Models.DynamicPublishedContentList
I am writing this from the parent template to show the child pages within it. The nupicker value is on each child page so would the follow still work?
var dynamicvar = CurrentPage.MyNupickerAlias.AsDynamicPublishedContent().Single();
Steph
Did you ever come up with a working solution for this situation?
Stephanie, I would also be interested if you were successful in this. Currently I am trying to resolve a property value contained in a nupicker inside the Orderby clause of a where statement. Failing that I'm looking for a way to generate another list that I can pre-populate and then resolve the picker values and do a sort based on that... any ideas apprecated.
is working on a reply...