Copied to clipboard

Flag this post as spam?

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


  • Max 80 posts 437 karma points
    Aug 29, 2017 @ 16:03
    Max
    0

    7.6 Multinode Treepicker - Property Value Converter

    From the 7.6.2(3) upgrade notes:

    In Umbraco version 7.6.2 we made a mistake in the Property Value Converts (PVCs) which was corrected 2 days later in version 7.6.3. If you were having problems with querying the following datatypes in the frontend, then make sure to upgrade to 7.6.3:

    • Multi Node Tree Picker
    • Related Links
    • Member Picker

    How do I access the Multi Node Tree Picker values from my Macro Parameters? This doesn't work if I enable property value converters:

    My View:

    @Umbraco.RenderMacro("HighlightSection", new { SelectedHighlightSections = CurrentPage.selectedHighlights })  // content type multi node tree picker property editor
    

    My Macro:

        @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{
        var items = Model.MacroParameters["SelectedHighlightSections"].ToString().Trim();
    
        string[] _items = new string[0] { };
    
        _items = (items.Length > 0) ? items.Split(',') : _items;
        }
    @if (_items.Length > 0)
        {
        <section id="highlight-section" class="sections highlight-section">
            <div class="container-fluid">
                <div class="row text-center">
                    @for (var i = 0; i < _items.Length; i++)
                    {
                        var item = Umbraco.TypedContent(_items[i]);
    ..... more stuff
    

    if i change:

    var items = Model.MacroParameters["SelectedHighlightSections"].ToString().Trim();
    

    To:

    var items = Model.MacroParameters["SelectedHighlightSections"]; // .ToString().Trim();
    

    When I debug "var items" it returns:

    Value: "System.Collections.Generic.List`1[Umbraco.Core.Models.IPublishedContent]"

    Type: object {string}

  • Max 80 posts 437 karma points
    Aug 30, 2017 @ 12:42
    Max
    0

    Can I still use MultiNode TreePicker as a parameter value in my macro if I enable property value converters?

  • Max 80 posts 437 karma points
    Aug 30, 2017 @ 19:39
    Max
    101

    I went backwards on this... to make it work...

            @{
                int[] _selectedHighlights = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("selectedHighlights")
                    .Select(x => x.Id).ToArray<int>();
            }
    
            @Umbraco.RenderMacro("HighlightSection", new { SelectedHighlightSections = string.Join(",", _selectedHighlights) })
    

    Then: In my macro I split the string CSV array of Ids as I had previously.

Please Sign in or register to post replies

Write your reply to:

Draft