How to create a CustomField for News?

Posted by Community Admin on 03-Aug-2018 21:28

How to create a CustomField for News?

All Replies

Posted by Community Admin on 13-Apr-2011 00:00

I am trying the following:

using Telerik.Sitefinity.Configuration;
using Telerik.Sitefinity.Web.UI;
using Telerik.Sitefinity.Web.UI.Fields.Config;
using Telerik.Sitefinity.Web.UI.Fields.Definitions;
 
namespace QUAY.Sitefinity.Modules
    public class ThumbFieldElementDefinition : TextFieldDefinition
    
        public ThumbFieldElementDefinition() : base()
        public ThumbFieldElementDefinition(ConfigElement element) : base(element)
    
 
    public class ThumbFieldElement : TextFieldDefinitionElement
    
        public ThumbFieldElement(ConfigElement parent) : base(parent)
 
        public override DefinitionBase GetDefinition()
        
            return new ThumbFieldElementDefinition(this);
        
    

And my control (CustomControl is a class that inhehits from CompositeControl)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using QUAY.Web.UI;
using Telerik.Sitefinity.Web.UI;
using Telerik.Sitefinity.Web.UI.Fields;
using Telerik.Sitefinity.Web.UI.Fields.Enums;
using Telerik.Web.UI;
using Telerik.Sitefinity.Web.UI.Fields.Contracts;
using Telerik.Sitefinity.Web.UI.Extenders.Definitions;
 
namespace QUAY.Sitefinity.Modules
    [FieldDefinitionElement(typeof(ThumbFieldElement))]
    public class ThumbField : CustomControl, IField
    
        private Label titleLabel;
        private TextBox textBox;
        private HyperLink selectLink;
 
 
        #region IField Members
 
        public void Configure(IFieldDefinition definition)
        
            //ITextFieldDefinition definition2 = definition as ITextFieldDefinition;
            //if (definition2 != null)
            //
            //    ExpandableControlDefinition definition3 = new ExpandableControlDefinition();
            //    definition3.ControlDefinitionName = definition2.ControlDefinitionName;
            //    definition3.ViewName = definition2.ViewName;
            //    definition3.SectionName = definition2.SectionName;
            //    definition3.FieldName = definition2.FieldName;
            //    definition3.Expanded = definition2.ExpandableDefinition.Expanded;
            //    //this.ExpandableControlDefinition = definition3;
            //    //this.Expanded = definition2.ExpandableDefinition.Expanded;
            //    //this.Rows = definition2.Rows;
            //    //this.value = definition2.Value;
            //    //this.Value = definition2.Value;
            //    //this.HideIfValue = definition2.HideIfValue;
            //
        
 
        public string Description
        
            get
            
                return "Image";
            
            set
            
            
        
 
        public string Example
        
            get
            
                return "Image";
            
            set
            
            
        
 
        public string ResourceClassId
        
            get
            
                return "Image";
            
            set
            
            
        
 
        public string Title
        
            get
            
                return "Image";
            
            set
            
            
        
 
        #endregion
    


I've create a custom field with the type:
QUAY.Sitefinity.Modules.ThumbField, QUAY.Sitefinity.Modules

It does work, I can see the control, the control works perfectly except that:
- All other fields in the news comes in blank.

Removing the custom fields restores everything back to normal. Why my control doesn't work? And how can I retrieve the Value saved on this field?



Posted by Community Admin on 14-Apr-2011 00:00

Hi Bruno,

You can take a look at this post

www.sitefinity.com/.../creating_a_thumbnail_selector_for_news_items.aspx

Kind regards,
Ivan Dimitrov
the Telerik team


Posted by Community Admin on 14-Apr-2011 00:00

I am getting errors with that sample which prevents me from saving the news.

This control I made works, but I get all fields empty. What if I didn't want a image selector but a custom field selector? How could I make it?

---

Inheriting from TextField and overriding the controls and InitializeControls is even worse. The entire page bugs and no value is retrieved on the other fields.

http://i.imgur.com/g2Uwz.png

...........

http://i.imgur.com/fn3we.png

Posted by Community Admin on 15-Apr-2011 00:00

If anyone run on this problem be sure to:

Put the assembly info of your website to SitefinityWebApp because somewhere in Telerek's it is hard coded.

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

hi,

in 4.1 i keep getting the attached image whenever i click 'Back to News' without
editing the news article at all. using IE8.

thanks,
andrei 

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

Hello Andrei,

"Back to News" is shown when you get an item for editing, so you mean that you are not editing the item fields/content? I am not able to replicate this issue with IE8. Are there issues with FF or Chrome?

Best wishes,
Ivan Dimitrov
the Telerik team


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

no, no issues in FF or Chrome. in IE8 however i found out that it does it only on a particular news item not on the others.
this 4.1 is behaving in some of the most strange ways. i guess i will have to delete that news item now???

andrei

Posted by Community Admin on 11-Jul-2012 00:00

Did you ever get this to work? I'm having the same problem with a DropDownList I added to the "basic" profile type. The label for the control is blank too.

Any help is appreciated,
Thanks,
Gary

This thread is closed