Copied to clipboard

Flag this post as spam?

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


  • René 327 posts 852 karma points
    Mar 04, 2014 @ 23:33
    René
    0

    MULTI-URL Picker

    Hi 

    Umbraco 6.1.6 -  Ucomponents 6

    A littel help is needed... :-)

    I´m struggeling to get the output from the multiurlpicker

    Here is what i have, i have been trying to get to work in many ways.

    @using umbraco.MacroEngines
    @inherits DynamicNodeContext
    @if (Model.AncestorOrSelf("StoreOption").HasValue("urlPicker"))
    {
        <p>test0</p>
        <ul>
        @foreach (var item in Model.AncestorOrSelf("StoreOption").GetPropertyValue<UrlPickerState>("urlPicker"))
        {
            <p>test1</p>
            @item
            {
                <li>test2</li>
            }
        }
        </ul>
    }
    

    The out put from this is:

    It continues until the end of the xml, any sugestions on how to get this to work?

    test0

      test1

      <
    • test2
    • test1

      m
    • test2
    • test1

      u
    • test2
    • test1

      l
    • test2
    • test1

      t
    • test2
    • test1

      i
    • test2
    • test1

      -
    • test2
    • test1

  • René 327 posts 852 karma points
    Mar 12, 2014 @ 00:06
    René
    1

    HI 

    Solved!

    This is for umbraco 6.1.6, uComponents6 Multi url picker

    This has the property "megamenu3" for the Multi Url Picker on the node "StoreOption

    @{                    
          if (Model.AncestorOrSelf("StoreOption").HasValue("megamenu3"))
                {
                  <ul class="sub-menu">
                   @foreach (var urlPicker in Model.AncestorOrSelf("StoreOption").megamenu3.Items)
                   {
                        if (urlPicker != null)
                        {
                        var urlPickerLinkTarget = (urlPicker.NewWindow) ? " target=\"_blank\"" : String.Empty;                            
                         <li>
                             <a href="@urlPicker.Url" @Html.Raw(urlPickerLinkTarget)>@urlPicker.Title</a>
                         </li>
                        }
                     }
                   </ul>
                 }
               }

     

    This is for umbraco 6.1.6, uComponents6 url picker

    Here the property is "urlPicker"

    @if (Model.HasProperty("urlPicker"))
        {
             var urlPicker = Model.urlPicker;
    if (urlPicker != null) { var urlPickerLinkTarget = (@urlPicker.NewWindow) ? " target=\"_blank\"" : String.Empty; <a href="@urlPicker.Url" @Html.Raw(urlPickerLinkTarget)>@urlPicker.Title <i class="icon icon-angle-right"></i></a> } }

    Here is more info:

    http://our.umbraco.org/projects/backoffice-extensions/ucomponents/questionssuggestions/22766-Retrieve-URL-Picker-data-in-Razor?p=2

     

    http://refreshwebsites.co.uk/blog/get-data-from-ucomponents-multi-url-picker/

  • John Halsey 59 posts 220 karma points
    Mar 12, 2014 @ 12:20
    John Halsey
    0

    This is really handy! I was having the exact same problem.

    In my case I'm using the Multi Url Picker to add related products. The products all have a "mainImage" and I was hoping to grab that out rather than just the title of the content item.

    Do you know how I might do that with Razor?

  • John Halsey 59 posts 220 karma points
    Mar 12, 2014 @ 12:36
    John Halsey
    0

    Actually I just worked this out. Here is my code for getting the image out of the related content item from the Multi URL Picker.

    if(Model.AncestorOrSelf("Product").HasValue("relatedProducts"))
            {
                <ul>
                    @foreach (var urlPicker in Model.AncestorOrSelf("Product").relatedProducts.Items)
                    {
                        if(urlPicker != null)
                        {
                            var linkTarget = (urlPicker.NewWindow) ? "target=\"_blank\"" : String.Empty;
                            var nodeId = urlPicker.NodeId;
                            var image = Library.NodeById(nodeId);
    
                            <li>
                                <a href="@urlPicker.Url" @Html.Raw(linkTarget)>
                                    <img src="@image.Media("mainImage","umbracoFile")" />
                                </a>
                            </li>
                        }
                    }
                </ul>
            }
    
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft