1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Custom dashboard control?

Custom dashboard control?

14 posts, 0 answered
  1. Chris
    Chris avatar
    57 posts
    Registered:
    12 Nov 2008
    27 Apr 2009
    Link to this post
    My users somehow have a tendency to start editing pages and then navigate away or just close their browser, leaving the page locked.

    To find out about such pages I would like to have a list of currently locked pages on my dashboard. Is there a way to add a custom module to the existing "My latest changes", "Last modified pages" etc.?

    Cheers, Chris
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    28 Apr 2009
    Link to this post
    Hi Chris,

    The dashboard supports section with last updated changed. check out attached screenshot. The option should be enabled by default. You can control what you want to see on the dashboard from "My Preferences" section (/Sitefinity/Admin/CmsAdmin/MyPreferences.aspx)

    If you want to create a custom implementation you can try adding some logic to /sitefinity/admin/Default.aspx and get a list of locked pages and their modifier.

    Sample code.

     protected void button1_Click(object sender, EventArgs e) 
        { 
            CmsManager manager = new CmsManager(); 
            IList listofPages = manager.GetPages(); 
            foreach (ICmsPage page in listofPages) 
            { 
                if (page.Staged.Locked) 
                    Response.Write(page.Name + "-" + page.Staged.Modifier + "<br />"); 
     
            } 

    I hope this helps.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    28 Apr 2009
    Link to this post
    Hi,
    It's not possible to change the stage programatically in this case to Saved ?

    Thanks
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    28 Apr 2009
    Link to this post
    Hello Pierre,

    To publish or save page you can call  manager.SavePage(page); or page.Publish();

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Chris
    Chris avatar
    57 posts
    Registered:
    12 Nov 2008
    28 Apr 2009
    Link to this post
    Hi,

    The "My latest changes" part does not show me locked pages from other users, so that's not an option.

    If I modify the /sitefinity/admin/Default.aspx file, it will be changed for everyone that uses the CMS unless I target specific users in the code behind - which I am trying to avoid by any means possible.

    The ideal solution would be to add a control in the /sitefinity/admin/controltemplates/personalization/ folder, and make it available for selection in the "My Preferences" section. If that is not possible yet, please consider it as a future feature. It would be a great improvement to be able to fully customize ones dashboard options.

    Cheers, Chris
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    01 May 2009
    Link to this post
    Hello Chris,

    It is not possible to have "Status" and "Modified by" columns in the grid for "My latest changes", because the implementation there is different and there is no DataBind(); as it is done for Pages.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Chris
    Chris avatar
    57 posts
    Registered:
    12 Nov 2008
    04 May 2009
    Link to this post
    As I wrote, I do not want to use the "My Latest Changed" control anyway. I am interested in all locked pages, not only the ones I modified.

    My question was: Is it possible to add custom controls, so they are available for selection in the "My Preferences" section? If yes, how?

    Cheers, Chris
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 May 2009
    Link to this post
    Hello Chris,

    This approach seems to be more complex than just crating an control since you need to create a custom module. As you see below we have IPersonalizedItem which is shown on our dashboard.

             foreach (IWebModule module in ModuleManager.WebModules.Values) 
                { 
                    IPersonalizedDashboard personalizedModule = module as IPersonalizedDashboard; 
     
                    if (personalizedModule != null
                    { 
                        foreach (IPersonalizedDashboardItem item in personalizedModule.DashboardItems) 
                        { 
                            plhDashboardItems.Controls.Add((WebControl)item); 
                        } 
                    } 
                } 

    So you need to create a custom module that implement the abstract class for WebModule and inherits from IPersonalizedDashboard. Then implement interface for Personalized Dashboard item.

    Here is a sample implementation( the code is attached as an archive file as well).

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik; 
    using Telerik.Personalization; 
    using System.Web.UI.WebControls; 
    using System.Web.UI; 
    using System.ComponentModel; 
    using System.Diagnostics; 
     
    /// <summary> 
    /// Summary description for MyModule 
    /// </summary> 
    public class HelloWorldModule : WebModule, IPersonalizedDashboard 
        public HelloWorldModule() 
        { 
            // 
            // TODO: Add constructor logic here 
            // 
        } 
     
        public override string Name 
        { 
            get { return "HelloWorldModule"; } 
        } 
     
        public override string Title 
        { 
            get { return "Hello World Module"; } 
        } 
     
        public override string Description 
        { 
            get { return "Hello World Module"; } 
        } 
     
        public override IList<Telerik.Web.IToolboxItem> Controls 
        { 
            get { return null; } 
        } 
        #region IPersonalizedDashboard Members 
     
        public IDictionary<stringstring> DashboardSettings 
        { 
            get  
            { 
                IDictionary<stringstring> dict = new Dictionary<stringstring>(); 
                dict.Add("myKey""My Key"); 
                return dict; 
            } 
        } 
     
        public IList<IPersonalizedDashboardItem> DashboardItems 
        { 
            get  
            { 
                List<IPersonalizedDashboardItem> list = new List<IPersonalizedDashboardItem>(); 
                if (PersonalizationManager.DefaultInstance.GetGlobalValue("myKey", Telerik.Personalization.Configuration.ConfigHelper.Handler.DashboardVisibilitySettings.IsVisible("myKey"))) 
                { 
                    list.Add(new MyPersonalizedDashboardItem()); 
                } 
                return list; 
            } 
        } 
        #endregion 
     
        public class MyPersonalizedDashboardItem : CompositeControl, IPersonalizedDashboardItem 
        { 
            protected override void CreateChildControls() 
            { 
                this.Controls.Add(new LiteralControl("Hello World!")); 
            } 
            #region IPersonalizedDashboardItem Members 
     
            [Category("Appearance")] 
            public virtual string Title 
            { 
                get 
                { 
                    return "Hello World"
                } 
                set 
                { 
                } 
            } 
     
            [Category("Behavior")] 
            public virtual string CloseSettingKey 
            { 
                get 
                { 
                    return string.Empty; 
                } 
                set 
                { 
                } 
            } 
     
            [Category("Behavior")] 
            public virtual string RowPerPageSettingKey 
            { 
                get 
                { 
                    return string.Empty; 
                } 
                set 
                { 
                } 
            } 
     
            public virtual string TemplatePath 
            { 
                get 
                { 
                    return string.Empty; 
                } 
                set 
                { 
                } 
            } 
     
            [DefaultValue(true)] 
            public virtual bool ShowProviderName 
            { 
                get 
                { 
                    return true
                } 
                set 
                { 
                } 
            } 
     
            /// <summary> 
            /// Gets or sets the index of the provider column. 
            /// </summary> 
            /// <value>The index of the provider column.</value> 
            [DefaultValue(-1)] 
            public virtual int ProviderColumnIndex 
            { 
                get 
                { 
                    return -1; 
                } 
                set 
                { 
                } 
            } 
     
            /// <summary> 
            /// Gets or sets the name of the module. 
            /// </summary> 
            /// <value>The name of the module.</value> 
            [Browsable(false)] 
            public string ModuleName 
            { 
                get 
                { 
                    return string.Empty; 
                } 
                set 
                { 
                } 
            } 
            #endregion 
        } 
     
     

    You can control the default value of your key through the web.config

    <dashboardVisibilitySettings> 
            <add key="HelloWorld" value="true"/> 


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Chris
    Chris avatar
    57 posts
    Registered:
    12 Nov 2008
    07 May 2009
    Link to this post
    Thanks, that's exactly what I was looking for!

    Only one thing: Please delete the "public HelloWorldModule(){}" constructor in your example. This prevents the module from being displayed anywhere, with no errors or warnings showing up. It's just like it wouldn't exist.

    Cheers, Chris
  10. Chris
    Chris avatar
    57 posts
    Registered:
    12 Nov 2008
    11 May 2009
    Link to this post
    Just a little follow-up: The control is working fine now, although the documentation on the whole dashboard area is very limited and does not contain any information that wouldn't be displayed by IntelliSense anyway.
    Example of IPersonalizedDashboardItem.ShowProviderName
    If such a page is supposed to tell me anything, I apologize. But so far, there are a just questions popping up: What is the provider name? What is the effect if I set it to true or false? The same is true for the rest of the IPersonalizedDashboardItem and most related classes.

    Anyway, the only thing I couldn't figure out yet is how to store personal settings for the dashboard control, such as the number of rows that are displayed in the existing controls.
    Do you have any documentation or sample code (for the number of rows example) that would show how to do that?

    Thanks, Chris
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 May 2009
    Link to this post
    Hi Chris,

    For the default value of rows you should use DefaultRecentItem Field ModuleSettingConstants.DefaultRecentItem or use RowPerPageSettingKey.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  12. Chris
    Chris avatar
    57 posts
    Registered:
    12 Nov 2008
    12 May 2009
    Link to this post
    Thanks for the buzzwords. Now, if there was some documentation I could help myself. However, this seems to be the only information available:
    ModuleSettingConstants.DefaultRecentItem
    IPersonalizedDashboardItem.RowPerPageSettingKey

    Now again, there's nothing but questions popping up:
    Why is the RowPerPageSettingKey a string? Rows per page clearly calls for a number.
    If I change it to "5" in my code, it does not seem to have any effect at all. How do I use it?

    Just by the name of the DefaultRecentItem I would never have guessed that to be part of the solution. Then again, how is it used? There are no examples anywhere.

    Sorry for bugging you like that. I usually really take my time to figure out things by myself, but there's just no way here. Except for the above linked pages there's no information on Google, the SF forum or KB, or anywhere on the SF or Telerik websites. And I just don't feel like starting to disassemble your dlls.

    If the forum is the wrong place for such a specific problem, please let me know and I'll open a support ticket instead. Just thought other people might run into a similar issue as well.
    Any help would be greatly appreciated!

    Thanks, Chris
  13. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    19 May 2009
    Link to this post
    Hi Chris,

    Here is explanation of personalization that can be made to the Sitefinity's modules.

    The dashboard controls use the PersonalizationManager class to persist values like the number of rows to show in their tables. The PersonalizationManager has methods 
    public T GetModuleValue<T>(string keyName, string moduleName, T defaultValue); 
    and 
    public void SaveModuleValue<T>(string keyName, string moduleName, T value)
    They save or retrieve the key value pairs in the database for the currently logged in user.

    There are several important interfaces and classes:
    • IPersonalizedDashboardItem - defines the main properties that every dashboard control must implement. A concrete implementation of this interface is the PersonalizedDashboardItem class - which is used for all dashboard control that are shown in the dashboard. It displays a table and a drop-down list for selecting the rows to show in the table. The properties of the control are ShowProviderName (whether the Provider column to be visible in the table), RowPerPageSettingKey (how many rows to be shown in the table). The RowPerPageSettingKey is a key used to retrieve the actual integer value saved in the database. 

    Note:   To get the actual RowPerPage you should invoke this method of the PersonalizationManagerGetModuleValue<int>(RowPerPageSettingKey , ModuleName, GlobalSettingConstants.DefaultRecentItem) and it will return the integer - how many rows per page. The default value GlobalSettingConstants.DefaultRecentItem is used if no such key is found in the database for the module.

    • IPersonalizedDashboard - this interface defines the controls that should be shown in the dashboard of Sitefinity. Its DashboardSettings property defines a key value pairs of settings. The DashboardItems  property returns the dashboard controls for the module. One typical scenario how to create a dashboard control for your module is to use the PersonalizedDashboardItem and return it in the DashBoardItems of your module. 

    I suggest you to use the PersonalizedDashboardItem class. Just set its properties (for example DataSource is the data that will show in the table).

    I hope this information will help you.

    Sincerely yours,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  14. Chris
    Chris avatar
    57 posts
    Registered:
    12 Nov 2008
    22 May 2009
    Link to this post
    Now that was some good information! By kicking the IPersonalizedDashboardItem interface and directly inheriting from the PersonalizedDashboardItem class, my code just shrunk from 200 lines to a mere 70, and the "Rows per page" finally work.

    Thanks!
    Chris
Register for webinar
14 posts, 0 answered