Extending Sitefinity Downloadlist Widget
I'm wondering if we can extend the sitefinity built-in widget design view. What I want to do, say for "Download list", I want to add new fields "Download List Title" or "Summary" or whatever fields and have it display on the page. I still like to keep all the widget design view functionalities but just add some more fields.
May be too easy/obvious answer but I'm still learning user controls so appreciate if someone could guide me along.
Thanks.
Hi May,
You have to create a new Custom control, inheriting the DownloadList control.
Here are some guides on creating custom controls:
http://www.sitefinity.com/blogs/ivan/posts/11-01-18/implementing_sitefinity_widgets_and_designers_how_to_implement_facebook_like_button.aspx
http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-controls-working-with-control-designers-creating-a-simple-control-designers.html
http://www.sitefinity.com/40/help/developers-guide/how-to-how-to-create-a-simple-image-selector.html
Basically, what you'll need to do is create a new assembly (or you can use a folder inside your SitefinityWebApp). In this assembly, you will have to add:
1) An .ascx file which will use one (or more) of the View templates of the current DownloadList control. You can copy the desired template code from (Design >> Widget Templates) and add for example a Label (which will hold the title) to it. Mind that you will have to change the template of all the Views, if you want all of them to have this title displayed.
This is the frontend template of the control.
2)An .ascx file which will use one of the control's designer templates, extending it with a textbox (for example) which will hold the input of the title. This one of the Views that you see when you click the edit button of your widget (it has two Views currently - Settings and Documents & Files)
3) A class that inherits from the actual control's class. This will be the file that you will use when registering your control in Sitefinity's Backend:
using System;using System.Collections.Generic;using System.Linq;using System.Web;using Telerik.Sitefinity.Modules.Libraries.Web.UI.Documents;using Telerik.Sitefinity.Web.UI.ControlDesign;using Telerik.Sitefinity.Modules.Pages.Web.UI;using Telerik.Sitefinity.Web.UI.PublicControls;namespace SitefinityWebApp.Tests [RequireScriptManager] [ControlDesigner(typeof(CustomDesigner))] [PropertyEditorTitle(typeof(PublicControlsResources), "DownloadList")] public class NewFrontendView : DownloadListView [ControlDesigner(typeof(CustomDesigner))]).
4) A class that inherits from the designer of the DownloadList control:using System;using System.Collections.Generic;using System.Linq;using System.Web;using Telerik.Sitefinity.Modules.Libraries.Web.UI.Designers;namespace SitefinityWebApp.Tests public class CustomDesigner : DownloadListDesigner protected override void AddViews(Dictionary<string, Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesignerView> views) var selectorView = new MyView(); var settingsView = new DownloadListSettingsDesignerView(); views.Add(selectorView.ViewName, selectorView); views.Add(settingsView.ViewName, settingsView); using System;using System.Collections.Generic;using System.Linq;using System.Web;using Telerik.Sitefinity.Modules.Libraries.Web.UI.Designers;using Telerik.Sitefinity.Web.UI;namespace SitefinityWebApp.Tests public class MyView : DownloadListSelectorDesignerView public static readonly string newTemplatePath = "~/MyControls/SitefinityWebApp.Tests.NewTemplate.ascx"; public override string LayoutTemplatePath get if (string.IsNullOrEmpty(this.layoutTemplatePath)) return this.layoutTemplatePath = newTemplatePath; return this.layoutTemplatePath; set this.layoutTemplatePath = value; private string layoutTemplatePath; Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Did you get this to work? We are trying to do the exact same thing but I can't get the javascript binding to work. If you did get a title or summary working for the download list could you post your solution?