I have a simple page with an MNTP for selecting a number of items to show (the items are all the same Doctype).
I would like to use a separate partial for rendering the items and ideally I'd like to use ModelsBuilder syntax inside the partial (so Model.Content.EmailAddress instead of Model.Content.GetProperty("emailAddress") but if that's not possible, I guess I'll have to live with it :-)
What's the ideal way to do this?
Just getting the items from the MNTP looks like it's way more work than it ought to be??
Which let me use ModelsBuilder syntax inside the partial.
So in the View currently doing the Split() thing, e.g.:
var people = Model.Content.People.Split(',');
@foreach (var personId in people) {
var person = Umbraco.TypedContent(personId);
@Html.Partial("Person", person)
}
This works, but it's ugly :)
Using the PropertyValue Converters could pretty this up, I guess - they will be built-in from v7.6.0 or so, right?
Render items from MNTP with ModelsBuilder
Hi all,
I have a simple page with an MNTP for selecting a number of items to show (the items are all the same Doctype).
I would like to use a separate partial for rendering the items and ideally I'd like to use ModelsBuilder syntax inside the partial (so
Model.Content.EmailAddress
instead ofModel.Content.GetProperty("emailAddress")
but if that's not possible, I guess I'll have to live with it :-)What's the ideal way to do this?
Just getting the items from the MNTP looks like it's way more work than it ought to be??
I'm using Umbraco v7.5.11 at the moment...
/Chriztian
Hi Chriztian,
Do I read this correctly...are you doing razor ?
But joking aside.
If you install this package : https://our.umbraco.org/projects/developer-tools/umbraco-core-property-value-converters/
And rebuild your models all your MNTP Picker properties will return an
IEnumerable<IPublishedContent>
So you can do something like this in Razor :
Dave
Thanks Dave,
Yes, I'm actually spending waaaay too much time in Razor - not my happiest place to be honest :-)
I kind of figured it out - I can actually just "declare" my partial:
Which let me use ModelsBuilder syntax inside the partial.
So in the View currently doing the
Split()
thing, e.g.:This works, but it's ugly :)
Using the PropertyValue Converters could pretty this up, I guess - they will be built-in from v7.6.0 or so, right?
Thanks again for chipping in,
/Chriztian
Hi Chriztian,
I understand. Had to fix a xslt macro on a old v4 site a while ago...felt like meeting an old girl friend and you don't remember her name.
Yes. I read somewhere that it will be part of the core. Just don't remember if it's 7.6 or 7.7
I believe it's in 7.6 (according to the feature list) ;) https://our.umbraco.org/contribute/releases/760
is working on a reply...