Copied to clipboard

Flag this post as spam?

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


  • Magnus Söderlund 19 posts 79 karma points
    Nov 20, 2013 @ 15:37
    Magnus Söderlund
    0

    Render a custom datatype

    Hello.

    Im interested in rendering custom datatypes in my content templates.

    Say for instace i have a datatype with property editor dropdown list and a set of prevalues. I would like to render a dropdown list with those prevalues with an easy command so that i can then later change the type from a dropdown to something else and have my template be affected by the change without having to update any markup.

    This would then be used to build a search-module where user can apply filters by selecting values from dropdown lists, checkboxes etc.

    Any ideas on where to begin? Ive been able to render a dropdownlist with the appropriate values but i would like to be able to dynamically change that dropdown-list to something else in the future.

    This is my current setup:

    @helper fillDropDown(int thisPreValue)
    {
        XPathNodeIterator preValueRootElementIterator = umbraco.library.GetPreValues(thisPreValue);
        preValueRootElementIterator.MoveNext();
        XPathNodeIterator preValueIterator = preValueRootElementIterator.Current.SelectChildren("preValue", "");
    
    <div>
        <select name="type">
            @while (preValueIterator.MoveNext())
            {
                <option value="@preValueIterator.Current.Value" @if(@Request["type"] == @preValueIterator.Current.Value) { @Html.Raw("selected"); }>
                    @preValueIterator.Current.Value
                </option>
            }
        </select>
    </div>
    }

    Thank in advance.

Please Sign in or register to post replies

Write your reply to:

Draft