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;
protectedoverridevoid 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?
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.
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;
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.
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:
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?
Have a look at this topic: http://our.umbraco.org/projects/backoffice-extensions/digibiz-advanced-media-picker/digibiz-advanced-media-picker/23517-DAMP-10-in-custom-page. Hope it helps. Still want to blog about it one day...
Jeroen
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.
Here is some more code which hopefully makes you understand the sample on the other page:
The dampSingleMediaItemIdDatatype:
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.
Get the value when trying to save in your custom section:
Let me know if you have any other questions.
Jeroen
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.
Hi Jeroen!
Based on you example above, how it is possible to load multiple images during load?
Thanks, Istvan
is working on a reply...