Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bruce Canino 21 posts 42 karma points
    Apr 02, 2013 @ 18:03
    Bruce Canino
    0

    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

  • Bruce Canino 21 posts 42 karma points
    Apr 02, 2013 @ 19:10
    Bruce Canino
    0

    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?

  • Bruce Canino 21 posts 42 karma points
    Apr 02, 2013 @ 19:20
    Bruce Canino
    0

    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.


Please Sign in or register to post replies

Write your reply to:

Draft