SaaS CMS has officially launched! Learn more now.

Custom display template for media in Xhtml editor

Vote:
 

Is it possible to create your ownd displaytemplate for ImageData or Media in the xhtmleditor? If yes how? In this case I am using webforms but would be nice to know if it is working for MVC as well? I cant find any example for displaying media diffrently in the editor.

#89652
Aug 21, 2014 14:54
Vote:
 

Hi,

It's very easy. In webforms you just create a user control and inherit from ContentControlBase, just like you would do for content areas:

    [TemplateDescriptor(Inherited = true)]
    public partial class ImageControl : ContentControlBase
    {
        protected Injected UrlResolver { get; set; }

        protected string ImageUrl
        {
            get
            {
                return UrlResolver.Service.GetUrl(CurrentData.ContentLink);
            }
        }
    }

One warning though, the image will be rendered as a block element in the editor, so it's not possible to have it floating next to the text.

#89663
Aug 21, 2014 18:13
Vote:
 

For future reference this is how it is done in MVC when dropping a page in the editor.

   [UIDescriptorRegistration]
    public class PageBaseDescriptor : UIDescriptor<PageData>, IEditorDropBehavior
    {
        public EditorDropBehavior EditorDropBehaviour { get; set; }

        public PageBaseDescriptor()
        {
            EditorDropBehaviour = EditorDropBehavior.CreateContentBlock;
        }
    }
#120090
Apr 10, 2015 7:58
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.