-
-
Save sniffdk/5457886 to your computer and use it in GitHub Desktop.
// Typed | |
var ids = Model.Content.GetPropertyValue<string>("mNTP", true, "").Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries); | |
var items = Umbraco.TypedContent(ids); | |
// Dynamic | |
@if (CurrentPage.HasValue("mNTP", true)) | |
{ | |
var ids = CurrentPage._mNTP.Split(','); | |
var items = Umbraco.Content(ids); | |
foreach (var item in items) | |
{ | |
<p>@item.Name</p> | |
} | |
} |
But for me the _property as recursive property doesn't seem to work.
This is the exact snippet that comes with Umbraco v6
@inherits umbraco.MacroEngines.DynamicNodeContext
@*
Macro to list nodes from a Multinode tree picker, using the pickers default settings.
Content Values stored as xml.
To get it working with any site's data structure, simply set the selection equal to the property which has the multinode treepicker.
*@
@{
var selection = Model.PropertyWithPicker;
}
@* Lists each selected value from the picker as a link *@
<ul>
@foreach(var id in selection){
@*For each link, get the node, and display its name and url*@
var node = Library.NodeById(id.InnerText);
<li><a href="@node.Url">@node.Name</a></li>
}
</ul>
Theoretically saying @node._Name should make it recursive (if I understand it correctly) but it does not work in my (very similary) code.
As I wrote on Twitter, that example uses the old MacroEngines api, it seems it haven't been updated to the new IPublishedContent api. And yes, prefixing a property name, when using dynamic, will make the property recursive. Is there a reason why you won't make due with the code I provided? I'm not sure why you insist on using the old api? And I'm not sure what "does not work" means, could use a little more detail :)
I didn't say, I wouldn't use your solution. I'm just saying your snippet looks more complicated than the one provided by Umbraco itself and I want to understand what the problem is before I switch. And when I say it doesn't work I just mean the values for the properties are not used (banner doesn't show anywhere) when I use underscore.
Anyway, thank you for your help. I have now enough material to go on. I'll post back when I have a working solution.
It's closer to this solution from here: http://our.umbraco.org/projects/backoffice-extensions/ucomponents/questionssuggestions/26638-Multi-Node-Tree-Picker-help-with-example-code-(in-Razor):
}