Details view for custom module

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

Details view for custom module

All Replies

Posted by Community Admin on 05-May-2011 00:00

Hi,

I've gone through the article How to create a custom content-based module in the Developers Guide but I want to extend the control a bit more. I want to add a Job details view so that when I click on a job in the JobApplicationsOverviewTemplate it would load the details of that job in a seperate page. How can I achieve this?

Thanks

Posted by Community Admin on 06-May-2011 00:00

Hi Raihan,

You need to create DetailsView for your widget in the module definition

#region View Definitions

            controlDefinition.ViewsConfig.AddLazy(FrontendListViewName, () =>
                new ContentViewMasterElement(controlDefinition.ViewsConfig)
               
                    ViewName = FrontendListViewName,
                    ViewType = typeof(Telerik.Sitefinity.Samples.Module.Web.UI.Public.MasterView),
                    AllowPaging = true,
                    DisplayMode = FieldDisplayMode.Read,
                    ItemsPerPage = 20,
                    ResourceClassId = typeof(ModuleResources).Name,
                    FilterExpression = DefinitionsHelper.PublishedOrScheduledFilterExpression,
                    SortExpression = "PublicationDate DESC"
                );


            controlDefinition.ViewsConfig.AddLazy(FrontendDetailViewName, () =>
                new ContentViewDetailElement(controlDefinition.ViewsConfig)
               
                    ViewName = FrontendDetailViewName,
                    ViewType = typeof(Telerik.Sitefinity.Samples.Module.Web.UI.Public.DetailsView),
                    ShowSections = false,
                    DisplayMode = FieldDisplayMode.Read,
                    ResourceClassId = typeof(ModuleResources).Name
                );

            #endregion


In your control you should set the views

public override string MasterViewName
       
            get
           
                if (string.IsNullOrEmpty(base.MasterViewName))
                    return ModuleDeifinition.FrontendListViewName;

                return base.MasterViewName;
           
            set
           
                base.MasterViewName = value;
           
       

        /// <summary>
        /// Gets or sets the name of the detail view to be loaded when
        /// control is in the ContentViewDisplayMode.Detail
        /// </summary>
        /// <value></value>
        public override string DetailViewName
       
            get
           
                if (string.IsNullOrEmpty(base.DetailViewName))
                    return ModuleDeifinition.FrontendDetailViewName;
                
                return base.DetailViewName;
           
            set
           
                base.DetailViewName = value;
           
      

Best wishes,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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 06-May-2011 00:00

Thanks for the response. It seems my custom module is a bit different. Can you please check the attached module file and then make the changes there? It would be really helpful.

using System;
using System.Linq;
using BiasMed.Modules.PublicControls;
using Telerik.Sitefinity;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Configuration;
using Telerik.Sitefinity.Libraries.Model;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Model;
 
namespace MyApp.Modules
    public class ArticleModule : ModuleBase
    
        public const string ModuleName = "Article";
 
        /// <summary>
        /// Gets the CLR types of all data managers provided by this module.
        /// </summary>
        /// <value>An array of <see cref="T:System.Type"/> objects.</value>
        public override Type[] Managers
        
            get
            
                return null;
            
        
 
        /// <summary>
        /// Initializes the service with specified settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        public override void Initialize(ModuleSettings settings)
        
            base.Initialize(settings);
        
 
        public override Guid LandingPageId
        
            get
            
                return ArticleModule.landingPageId;
            
        
        public Guid SubPageId
        
            get
            
                return ArticleModule.subPageId;
            
        
 
        /// <summary>
        /// Installs this module in Sitefinity system.
        /// </summary>
        /// <param name="initializer">The Site Initializer. A helper class for installing Sitefinity modules.</param>
        public override void Install(SiteInitializer initializer)
        
            bool restart = false;
            this.EnsureMetaFields(ref restart);
 
            using (var sf = App.WorkWith())
            
                sf.Page().PageManager.Provider.SuppressSecurityChecks = true;
 
                var moduleNode = sf.Page(SiteInitializer.ModulesNodeId).Get();
 
                var jobsNode = sf.Pages().Where(p => p.Id == this.LandingPageId).Get().SingleOrDefault();
                if (jobsNode == null)
                
                    sf.Page().CreateNewPageGroup(moduleNode, this.LandingPageId).Do(p =>
                    
                        p.Name = "Articles";
                        p.ShowInNavigation = true;
                        p.Attributes["ModuleName"] = ArticleModule.ModuleName;
                        p.Title = "Articles";
                        p.UrlName = "Articles";
                    );
                    restart = true;
                
 
                // Create the subpage
                var subPage = sf.Pages().Where(p => p.Id == this.SubPageId).Get().SingleOrDefault();
                if (subPage == null)
                
                    sf.Page().CreateNewStandardPage(this.LandingPageId, this.SubPageId).Do(p =>
                    
                        p.Name = "Articles";
                        p.UrlName = "Articles";
                        p.Description = "Articles Overview";
                        p.ShowInNavigation = false;
                        p.Attributes["ModuleName"] = ArticleModule.ModuleName;
                    ).CheckOut()
                            .Do(draft => draft.TemplateId = sf.Page().PageManager.GetTemplates().Where(t => t.Name == SiteInitializer.BackendTemplateName).SingleOrDefault().Id)
                            .Control().CreateNew(new ArticlesBackendControl(), "Content").Done()
                            .Publish();
                    restart = true;
                
            
 
            if (restart)
            
                SystemManager.RestartApplication(true);
            
        
 
         
 
        public static readonly Guid landingPageId = new Guid("82006664-3af9-47db-8ac0-6811e942ec44");
        public static readonly Guid subPageId = new Guid("f052be9d-f6ef-439b-964a-cb3d99eb9efc");
         
 
        protected override ConfigSection GetModuleConfig()
        
            return null;
        
 
        public override void Upgrade(SiteInitializer initializer, Version upgradeFrom)
        
        
 
        private void EnsureMetaFields(ref bool restart)
        
             
        
    


Thanks

Posted by Community Admin on 06-May-2011 00:00

Hi Raihan,

In the module class you should only register the pubic widget inside InstallConfiguration. Generally you need to have a definition class for your custom module where you set the widget views.

Regards,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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 06-May-2011 00:00

Thanks for the prompt response Ivan. Can you please post some code sample or link to a tutorial?

Posted by Community Admin on 06-May-2011 00:00

Hi Raihan,

You can download and check out Products sample module that comes with the SDK installation.

Best wishes,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed