Copied to clipboard

Flag this post as spam?

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


  • SC Digital Services Team 104 posts 171 karma points
    Aug 15, 2012 @ 15:46
    SC Digital Services Team
    0

    Using an existing datatype control within the prevalue settings of a custom datatype

    I've been tasked with creating a custom datatype to create a list of items as prevalues, which will then be parsed and rendered into a custom checkbox list usercontrol.

    Ideally, the each item in the prevalue list will contain an image and two strings. The strings represent a feature and additional information for that feature, both of which will form a single item in a checkbox list  - the feature forming the label, and the additional information being used as default values in a textbox. When the page is published, the selected items will be displayed on the page and use the associated images set in the prevalue settings for the icon of each item.

    I've managed to build the basic control with the two text values (see attached image), but was stumped when throwing images into the equation as I'm still new to Umbraco & .NET development. Is there a way of embedding the Media Picker control into my datatype to set prevalues (perhaps using DataEditorSetting?), or is there a simple way of constructing a drop-down list of available images from a folder within Media?

  • Matt Bliss 176 posts 234 karma points c-trib
    Aug 15, 2012 @ 17:23
    Matt Bliss
    1

    This sounds like a complicated approach to me. I might have misunderstood the requirement, but how about a simple approach using standard Umbraco features:

    • Create a new a 'venue' media type which has all the properties of the standard 'image' media type and then add two new text fields for your additional information.
    • Create a new folder in the media section to put all your venue media items in.
    • Create a new datatype (in the backend interface as opposed to code) which is a multi node tree picker type and set it to have your new media folder as the root folder.
    • Include this new datatype in any document types that require your 'venue' selection.
    • Modify an exisiting macro for displaying the selected media items in your templates.

    Hope this is helpful!

  • SC Digital Services Team 104 posts 171 karma points
    Aug 15, 2012 @ 17:42
    SC Digital Services Team
    0

    Thanks for this - it's definitely something I will try. The only thing I will need to figure out is how to allow editors to amend the second text field (although I've got a few ideas already).

  • Matt Bliss 176 posts 234 karma points c-trib
    Aug 15, 2012 @ 17:46
    Matt Bliss
    0

    Ah, that would be the part of the requirement that I had missed!

    Okay this is a bit of a fudge, but how about putting the fixed text entry in the new media type and then using the uComponents Multi-URL Picker (for which you only enable Media) and then use the title field for the variable second text entry.

    And if not then the source code might give you the answer to you original question about selecting media items in you own control.

  • SC Digital Services Team 104 posts 171 karma points
    Aug 15, 2012 @ 18:36
    SC Digital Services Team
    0

    No problem - I also forgot to mention that we have the prevalue option to "show" the additional details (by default it behaves just like a checkbox list datatype and doesn't allow the editors to edit/add the additional information). I've also been told that we may need other prevalues on this datatype to set a minimum and maximum of items an editor can select (e.g. there must be a minimum of 5, but no more than 10).

    In any case, I've been browsing the forums and have a couple of other approaches to explore if the new Media type doesn't solve our user's requirements:

    1. I might be able to botch together a custom drop-down list based on the uComponents "Image Drop-Down List" code. http://ucomponents.codeplex.com/SourceControl/changeset/view/1c29e8deabe6#uComponents.Core%2fDataTypes%2fImageDropdown%2fID_DataType.cs
      Failing that...
    2. I could create a datatype (using the uComponents IDDL) with the images I require, then grab these prevalues to build a drop-down list in my own custom datatype. - http://our.umbraco.org/forum/developers/api-questions/27544-Using-GetPreValues  &  http://our.umbraco.org/forum/developers/api-questions/2867-Get-custom-dropdown-datatype-values

     

     

  • SC Digital Services Team 104 posts 171 karma points
    Sep 18, 2012 @ 11:37
    SC Digital Services Team
    0

    Just to close this topic off - we've actually had to use a drop-down text list of available icons (which is configured in a different Data Type), and this value is used to set the class of the item on the page. 

    While building this we actually came across (and fixed) a bug with the core "Values" SettingsControl - the JavaScript breaks when you include non-alphanumeric characters (like "Fish & Chips") - now reported here: http://issues.umbraco.org/issue/U4-742

Please Sign in or register to post replies

Write your reply to:

Draft