I have a Umbraco page that has sevel uCompoments URL Picker controls. I am trying to write a macro that will take the URL Picker as a parameter. The marco will write out into a table for each control.
@{ var control = @Parameter.controlName; if (@Model.HasValue(control)) { var controlSelection = Model.GetProperty(control, true).Value; <tr><td>@controlSelection.ToString()</td></tr> } else { <tr><td>False</td></tr> } }
when done controlSelection is the xml of the Muilt URL picker. I tried like @controlSelect.multurlpicker but causes a error
@{ var control = @Parameter.controlName; if (@Model.HasValue(control)) { var xml = @Library.ToDynamicXml(Model.GetPropertyValue(control)); foreach(var value in xml) { <tr><td> @value.url.ToString()</td></tr> } } else { <tr><td>False</td></tr> } }
The anwsers where here, just not easy to find some time.
Pass URL Picker as Maco Parameter
I have a Umbraco page that has sevel uCompoments URL Picker controls. I am trying to write a macro that will take the URL Picker as a parameter. The marco will write out into a table for each control.
I have:
@using umbraco.MacroEngines
@inherits DynamicNodeContext
@{
var control = @Parameter.controlName;
if (@Model.HasValue(control))
{
<tr><td>True</td></tr>
<tr><td>@Model.control.urlpicker.ToString()</td></tr>
}
else
{
<tr><td>False</td></tr>
}
}
The "if (@Model.HasValue(control))" works fine and returns true, but I not sure how to use the control name with the @Model
@Model.control.urlpicker.ToString() <--- returns nothing
How do I use the name of the URL picker to access it.
TIA
My searching some more I found the following
@inherits DynamicNodeContext
@using umbraco.MacroEngines
@{
var control = @Parameter.controlName;
if (@Model.HasValue(control))
{
var controlSelection = Model.GetProperty(control, true).Value;
<tr><td>@controlSelection.ToString()</td></tr>
}
else
{
<tr><td>False</td></tr>
}
}
when done controlSelection is the xml of the Muilt URL picker. I tried like @controlSelect.multurlpicker but causes a error
how do I iterater over the xml?
Well I did find the answer.
@inherits DynamicNodeContext
@using umbraco.MacroEngines
@{
var control = @Parameter.controlName;
if (@Model.HasValue(control))
{
var xml = @Library.ToDynamicXml(Model.GetPropertyValue(control));
foreach(var value in xml) {
<tr><td> @value.url.ToString()</td></tr>
}
}
else
{
<tr><td>False</td></tr>
}
}
The anwsers where here, just not easy to find some time.
Hope this helps someone in the furture.
is working on a reply...