Copied to clipboard

Flag this post as spam?

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


  • Alex Wilks 27 posts 56 karma points
    Sep 15, 2011 @ 14:06
    Alex Wilks
    0

    Using DAMP in a custom section

     

    I've extended an Umbraco install with a new section and I would like to use the DAMP classic media picker along with some built in editor controls (such as textstring, textbox multiple, etc).

    The way I've been adding textfields is as follows:

     

    private umbraco.editorControls.textfield.TextFieldEditor title = null;
    
    protected override void OnInit(EventArgs e)
    {
        DataTypeDefinition d = DataTypeDefinition.GetDataTypeDefinition(-88);
        title = (umbraco.editorControls.textfield.TextFieldEditor)d.DataType.DataEditor;
        productTitle.Controls.Add(title);
    }

     

    This works well but if I follow the pattern with DAMP classic, I get the following error:

    Unable to cast object of type 'umbraco.cms.businesslogic.datatype.AbstractDataEditorControl' to type 'DigibizAdvancedMediaPicker.DigibizAdvancedMediaPicker'.

    Now I fully understand why I'm getting this error, I'm just not sure how to get DAMP to render out on the screen. Can anybody help?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Sep 15, 2011 @ 14:30
  • Alex Wilks 27 posts 56 karma points
    Sep 15, 2011 @ 16:10
    Alex Wilks
    0

    I wholeheartedly support your plan to blog about this!

    Thanks for the information and prompt response (don't know how that thread was missed when searching) but I'm still a little unsure about the code samples you provided.

    I tried Dans way and that presented an "Object reference not set to an instance of an object." error when casting from an AbstractDataEditorControl to a DAMP_DataEditor. Ive tried your samples too but I'm not sure what type "dampSingleMediaItemIdDatatype" is or what type "MenuImageValue" is so I'm unable to compile and test.

    Do you have any further advice please?

    Thanks in advace.

     

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Sep 15, 2011 @ 16:28
    Jeroen Breuer
    101

    Here is some more code which hopefully makes you understand the sample on the other page:

    The dampSingleMediaItemIdDatatype:

    //Get the [Digibiz] Select single media item datatype.
    DataTypeDefinition dampSingleMediaItemIdDatatype = DataTypeDefinition.GetDataTypeDefinition(1164);

    The MenuImageValue is a property in which an interger is stored. That is where you set the media id which you have in your custom section. Something like this:

    Set the value in DAMP in the load event.

    //Set value from the database in the [Digibiz] Select single media item datatype.
    _dampMenuImageDataEditor.Value = mediaId;

    //or another sample with a hard code 
    _dampMenuImageDataEditor.Value = 1255;

    Get the value when trying to save in your custom section:

    //Get the value from the [Digibiz] Select single media item datatype.
    //This will cause the the datatype to databind again so the newly selected items (with javascript) stay selected after the postback.
    int newMediaId = _dampMenuImageDataEditor.Value;

    Let me know if you have any other questions.

    Jeroen

  • Alex Wilks 27 posts 56 karma points
    Sep 15, 2011 @ 18:37
    Alex Wilks
    0

    That's awesome, thanks so much. I was very close but had neglected something in my aspx page. I wont say what because it's embarassing! But thanks for your help, it was invaluable.

  • Istvan Pszota 59 posts 191 karma points
    Jan 27, 2015 @ 20:59
    Istvan Pszota
    0

    Hi Jeroen!

    Based on you example above, how it is possible to load multiple images during load?

    Thanks, Istvan

Please Sign in or register to post replies

Write your reply to:

Draft