Add Album selector as custom field

Posted by Community Admin on 03-Aug-2018 13:16

Add Album selector as custom field

All Replies

Posted by Community Admin on 17-Jan-2011 00:00

I want to be able to add album  and image selector as as custom field to News or any other content type.
is this possible without coding , or do I have to create custom control for this?

cheers, Siggi

Posted by Community Admin on 18-Jan-2011 00:00

I think that the fields available for extending modules are in this namespace "Telerik.Sitefinity.Web.UI.Fields". You can find the "ImageField" class there, but if you try to add it it throws exception saying that the "FieldDefinitionElement" attribute is missing. Also, in the control template "Telerik.Sitefinity.Resources.Templates.Fields.ImageField.ascx" there is "alert('In process of implementation.')". So, I guess the field is not complete. I need to add image and video selector for some of the existing modules like you and I will welcome a solution from Telerik instead of taking the hard and painful path of workarounds. 

Posted by Community Admin on 18-Jan-2011 00:00

Hi Sigurþór Halldórsson,

As Ivan noted, the ImageField exists in Sitefinity, but you won't be able to use it in this case. Its only role for now is in the Sitefinity backend when editing image properties.
For your specific requirement you would have to create your own FieldControl and use that when creating the custom field.
That field control would be responsible for displaying the UI for selecting an image (from a library) and saving the value (ID or image URL, whatever you prefer) as the value of the custom field. You need to inherit from the FieldControl class, and your client component should inherit from the FieldControl sitefinity client component. You can do whatever you want with the UI, but make sure to implement the get_value() and set_value() client methods, which will be called by the dialog.
We will consider including such functionality in one of the future releases, but a custom field control is the only way to go for now.

Regards,
Slavo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 28-Jan-2011 00:00

Hi Slavo,

Can you please describe a little more that how can we make a control for our custom field? I have definition for my module`s backend and want to have a file upload control...I think I`ll need to have DefinitionElement for my use, right?
Can you please guide me a little more on this and provide a little sample or basic structure or classes required etc?

Posted by Community Admin on 03-Feb-2011 00:00

Hello Sigurþór Halldórsson,

You would need to do several things to implement a custom image selector:

  1. Implement a custom FieldControl (inherit from FieldControl class).
    The role of this control is to provide user interface which selects a value. Your challenge here would be to display a list of images and get the URL of the one clicked by the user. The only thing requried from it is to get and set the Value property with what you actually want to persist. You need a server-side and client-side component both inheriting from the corresponding FieldControl component (and both setting the value property - one on the client and one on the server).
  2. Implement a definition class (inheriting from FieldControlDefinition).
    This class is nothing else, but a collection of all properties of your fieldcontrol that you need to work with. You implement one property for each property in the actual control. If you don't have additional properties in step 1, you can just inherit and do nothing else.
  3. Definition configuration element (inheriting from FieldControlDefinitionElement)
    This is exactly like the definition in point 3, but acts to persist values in configuration. Again, you need one property for each property of the actual control.
Once you have implemented the above, you can use your custom control for new custom fields. Specify custom and provider the full Type name when creating the custom field.

I'll write a blog post explaining these things in more detail and providing sample code, so stay tuned and follow our blogs (http://www.sitefinity.com/blogs.aspx).

Best wishes,
Slavo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed