Custom Modules

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

Custom Modules

All Replies

Posted by Community Admin on 10-Jun-2010 00:00

Are Custom Type Editors supported in the CTP of SF4? I would like to build some custom modules but I'm running into a roadblock because the editors need to be more complex than textboxes.  I would like to create a custom module with an image, hyperlink (select target from a drop down list), and WYSIWYG editor.  Any ideas if this is possible this early? I'm looking forward to the Beta release...is it going to be early or late July?

Posted by Community Admin on 11-Jun-2010 00:00

Hi Shawn,

There will be support for custom WebUIType editor, but the implementation is a bit different than this one in 3.x edition.

Again you have a template with a controls

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
    <sitefinity:ResourceLinks id="resourcesLinks" runat="server">
    <sitefinity:ResourceFile JavaScriptLibrary="JQuery" />
    <sitefinity:ResourceFile Name="Skins/Grid.css" />
    <sitefinity:ResourceFile Name="Skins/ToolBar.css" />
    <sitefinity:ResourceFile Name="Skins/Ajax.css" />
</sitefinity:ResourceLinks>
 
 
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
 
<telerik:RadTreeView id="RadTreeView1" runat="server" DataSourceID="SiteMapDataSource1" Skin="Sitefinity" OnClientNodeClicked="function() return false;" >
        <DataBindings>
            <telerik:RadTreeNodeBinding ValueField="Id" />
        </DataBindings>
    </telerik:RadTreeView>
</div>
 
<p class="sfButtonArea sfSelectorBtns">
    <asp:LinkButton ID="DoneButton" runat="server" OnClientClick="return false;" CssClass="sfLinkBtn sfSave">DoneButton</asp:LinkButton>
    <asp:Literal ID="literalOr" runat="server" Text="<%$Resources:Labels, or %>" />
    <asp:LinkButton ID="CancelButton" runat="server" CssClass="sfCancel" OnClientClick="return false;">CancelButton</asp:LinkButton>
</p>

Then you have to create a class that inherits from Telerik.Sitefinity.Web.UI.SimpleScriptView and implement the selector

public class CustomDialogSelector: SimpleScriptView
   
       #region Public Methods
 
       public bool CheckBoxes
       
           get;
           set;
       
 
       #endregion
 
       #region Properties
 
 
 
       protected override string LayoutTemplateName
       
           get
           
               return templatePath;
           
       
 
       private RadTreeView SiteMapTreeView
       
           get
           
               return Container.GetControl<RadTreeView>();
           
       
 
       private LinkButton DoneButton
       
           get
           
               return Container.GetControl<LinkButton>("DoneButton", true);
           
       
 
       private string UseCheckboxes
       
           get
           
               return this.CheckBoxes.ToString().ToLower();
           
       
 
       private LinkButton CancelButton
       
           get
           
               return Container.GetControl<LinkButton>("CancelButton", true);
           
       

       public string OnDoneClientSelection
       
           get;
           set;
       
 
       #endregion
 
       #region Methods
 
       /// <summary>
       /// Gets a collection of script descriptors that represent (JavaScript) client components.
       /// </summary>
       public override IEnumerable<System.Web.UI.ScriptDescriptor> GetScriptDescriptors()
       
           var descriptor = new ScriptControlDescriptor(this.GetType().FullName, this.ClientID);
           descriptor .AddComponentProperty("siteMapTree", SiteMapTreeView.ClientID);
 
           scriptDescriptor.AddElementProperty("doneButton",DoneButton.ClientID);
           scriptDescriptor.AddElementProperty("cancelButton", CancelButton.ClientID);
           scriptDescriptor.AddProperty("checkboxes", UseCheckboxes);
           if (!string.IsNullOrEmpty(this.OnDoneClientSelection))
               scriptDescriptor.AddEvent("doneClientSelection", this.OnDoneClientSelection);
           return new[] scriptDescriptor ;
       
 
       /// <summary>
       /// Gets a collection of objects that define script resources that the control requires.
       /// </summary>
       public override IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences()
       
           // here you can return reference to a custom script that your control
           // will use.
           string assembly = this.GetType().Assembly.GetName().ToString();
           List<ScriptReference> res = new List<ScriptReference>
               new ScriptReference(selectorScript, assembly),
           ;
           return res;
       
 
       protected override void OnPreRender(EventArgs e)
       
           base.OnPreRender(e);
           var controlSiteMap = this.SiteMapTreeView;
           controlSiteMap .CheckBoxes = this.CheckBoxes;
           controlSiteMap .DataBind();
           controlSiteMap .ExpandAllNodes();
            
       
 
       protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
       
       
       #endregion
 
       #region Fields
 
       private const string selectorScript = "Telerik.Sitefinity.Samples.AlterScript.js";
       private const string templatePath= "Telerik.Sitefinity.Resources.Templates.Samples.PageTemplate.ascx";
       #endregion
   

We will provide SDK with sample scenarios and modules after the beta. Currently most of the things are not documented and there are API changes, so I suggest that you should start developing custom control/modules after the beta.


Sincerely yours,
Ivan Dimitrov
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 21-Oct-2010 00:00

Ivan,


That's a bit of a long way round. Below is a code example which used to work:
--------------------------
Imports System.ComponentModel
Imports Telerik.Sitefinity.Web.UI

Partial Class LogIn
    Inherits System.Web.UI.UserControl
    Private _destinationPageUrl As String = "~/Default.aspx"

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        LoginControl.DestinationPageUrl = DestinationPageURL
    End Sub

    <Category("Behavior"), _
    WebEditor("Telerik.Cms.Web.UI.CmsUrlWebEditor, Telerik.Cms")> _
    Public Property DestinationPageURL() As String
        Get
            Return _destinationPageUrl
        End Get
        Set(ByVal value As String)
            _destinationPageUrl = value
        End Set
    End Property

End Class
--------------------------

Can I not just add the correct WebEditor?

Many thanks,
Andrei

Posted by Community Admin on 21-Oct-2010 00:00

Hello Andrei,

We have not implemented WebEditors that you can use directly as a part of a public property in "Advanced" section of a control. You have to create a control designer as the previous posts suggests.
I believe that we will be able to finish and document web property editors for the official release.

Kind regards,
Ivan Dimitrov
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 21-Oct-2010 00:00

Ivan,


I will probably wait then. If you are a bit late then I shall have a look otherwise,
I will let you guys do the work :)

When shall I check with you again do you think? I need to start work on the
project in a couple of months time.

Thank you again for all your help.
Andrei

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

Are the WebEditors in the official release?

I tried the following, which I didn't think was correct anyway, but it didn't do anything.
[Telerik.Sitefinity.Web.UI.WebEditor("Telerik.Sitefinity.Web.UI.EditorExternalDialogModes.Document, Telerik.Sitefinity")]

Also, sorry to hijack, but is System.ComponentModel.DisplayNameAttribute supported for properties? SF seems to ignore the display name. Not a big deal if it's not.

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

Eric,

No they are not, and no Road-Map yet as to when they may be released. For now, its all about Custom Controls i'm afraid. There are quite a few threads on doing it through Custom Controls.

Have fun,
Andrei

This thread is closed