New Module

Posted by Community Admin on 03-Aug-2018 11:52

New Module

All Replies

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

I would really appreciate some pointers, I've based this attached module on the Jobs example but I've been unable to get it to list on the Dashboard > Content.


In System I set it up as Type: Rotator.RotatorModule and I make sure to check the install checkbox. I've tried restarting the site, restarting IIS, clearing my cache and rebooting my system but so far no luck. 

Is there something I missed with my code or am I following the wrong procedures when installing the module through the dashboard?

Thank you in advance.

001.using System;
002.using System.Linq;
003.using Telerik.Sitefinity;
004.using Telerik.Sitefinity.Abstractions;
005.using Telerik.Sitefinity.Configuration;
006.using Telerik.Sitefinity.Modules.Pages.Configuration;
007.using Telerik.Sitefinity.Services;
008.using Rotator.PublicControls;
009. 
010.namespace Rotator
011.
012.    /// <summary>
013.    /// A module for managing job application uploads and providing an overview thereof.
014.    /// </summary>
015.    public class RotatorModule : ModuleBase
016.    
017.        #region Fields
018. 
019.        /// <summary>
020.        /// The name of the module
021.        /// </summary>
022.        public const string ModuleName = "RotatorModule";
023. 
024.        /// <summary>
025.        /// The landing page id.
026.        /// </summary>
027.        private readonly Guid landingPageId = new Guid("13FA3CB0-6F00-4DFB-A534-28EA60252A17");
028. 
029.        /// <summary>
030.        /// The sub page id.
031.        /// </summary>
032.        private readonly Guid subPageId = new Guid("A52C36E1-3D29-4F39-BB8D-BB1F064E556B");
033. 
034.        #endregion
035. 
036.        /// <summary>
037.        /// Gets the CLR types of all data managers provided by this module.
038.        /// </summary>
039.        /// <value>An array of <see cref="T:System.Type"/> objects.</value>
040.        public override Type[] Managers
041.        
042.            get
043.            
044.                return null;
045.            
046.        
047. 
048.        /// <summary>
049.        /// Gets the landing page id for each module inherited from <see cref="T:Telerik.Sitefinity.Services.ModuleBase"/> class.
050.        /// </summary>
051.        /// <value>The landing page id.</value>
052.        public override Guid LandingPageId
053.        
054.            get
055.            
056.                return this.landingPageId;
057.            
058.        
059. 
060.        /// <summary>
061.        /// Gets the sub page id.
062.        /// </summary>
063.        /// <value>The sub page id.</value>
064.        public Guid SubPageId
065.        
066.            get
067.            
068.                return this.subPageId;
069.            
070.        
071. 
072.        /// <summary>
073.        /// Initializes the service with specified settings.
074.        /// </summary>
075.        /// <param name="settings">The settings.</param>
076.        public override void Initialize(ModuleSettings settings)
077.        
078.            base.Initialize(settings);
079.        
080. 
081.        /// <summary>
082.        /// Installs this module in the Sitefinity system.
083.        /// </summary>
084.        /// <param name="initializer">The Site Initializer. A helper class for installing Sitefinity modules.</param>
085.        public override void Install(SiteInitializer initializer)
086.        
087.            bool restart = false;
088.            //this.EnsureMetaFields(ref restart);
089. 
090.            using (var sf = App.WorkWith())
091.            
092.                int result;
093.                sf.DocumentLibraries().Where(l => l.Title == "Rotator").Count(out result);
094. 
095.                if (result < 1)
096.                
097.                    sf.DocumentLibrary().CreateNew().Do(lib =>
098.                    
099.                        lib.Title = "Rotator";
100.                        lib.UrlName = "Rotator";
101.                    );
102.                
103. 
104.                sf.Page().PageManager.Provider.SuppressSecurityChecks = true;
105. 
106.                var moduleNode = sf.Page(SiteInitializer.ModulesNodeId).Get();
107. 
108.                var rotatorNode = sf.Pages().Where(p => p.Id == this.LandingPageId).Get().SingleOrDefault();
109.                if (rotatorNode == null)
110.                
111.                    sf.Page().CreateNewPageGroup(moduleNode, this.LandingPageId).Do(p =>
112.                    
113.                        p.Name = "Rotator";
114.                        p.ShowInNavigation = true;
115.                        p.Attributes["ModuleName"] = RotatorModule.ModuleName;
116.                        p.Title = "Rotator";
117.                        p.UrlName = "Rotator";
118.                    );
119.                    restart = true;
120.                
121. 
122.                // Create the subpage
123.                var subPage = sf.Pages().Where(p => p.Id == this.SubPageId).Get().SingleOrDefault();
124.                if (subPage == null)
125.                
126.                    sf.Page().CreateNewStandardPage(this.LandingPageId, this.SubPageId).Do(p =>
127.                    
128.                        p.Name = "RotatorOverview";
129.                        p.UrlName = "RotatorOverview";
130.                        p.Description = "Rotator Overview";
131.                        p.ShowInNavigation = false;
132.                        p.Attributes["ModuleName"] = RotatorModule.ModuleName;
133.                    ).CheckOut()
134.                            .Do(draft => draft.TemplateId = sf.Page().PageManager.GetTemplates().Where(t => t.Name == SiteInitializer.BackendTemplateName).SingleOrDefault().Id)
135.                            .Control().CreateNew(new RotatorOverview(), "Content").Done()
136.                            .Publish();
137.                    restart = true;
138.                
139.            
140. 
141.            if (restart)
142.            
143.                SystemManager.RestartApplication(false);
144.            
145. 
146.            this.RegisterToolboxControl();
147.        
148. 
149.        /// <summary>
150.        /// Registers the public control inside the SF toolbox
151.        /// </summary>
152.        private void RegisterToolboxControl()
153.        
154.            string controlType = typeof(RotatorDisplay).AssemblyQualifiedName;
155.            var conf = Config.Get<ToolboxesConfig>();
156. 
157.            var pageControls = conf.Toolboxes["PageControls"];
158. 
159.            if (pageControls.Tools.Values.Count(x => x.Name == "RotatorDisplay") > 0)
160.            
161.                return;
162.            
163. 
164.            var section = pageControls
165.                .Sections
166.                .Where<ToolboxSection>(e => e.Name == "Custom")
167.                .FirstOrDefault();
168. 
169.            if (section == null)
170.            
171.                section = new ToolboxSection(pageControls.Sections)
172.                
173.                    Name = "Custom",
174.                    Title = "Custom widgets",
175.                    Description = "A section storing custom widgets"
176.                ;
177.                pageControls.Sections.Add(section);
178.            
179. 
180.            section.Tools.Add(new ToolboxItem(section.Tools)
181.            
182.                ControlType = controlType,
183.                ModuleName = RotatorModule.ModuleName,
184.                Name = "RotatorDisplay",
185.                Title = "Rotator Public Display",
186.                Description = "The Public view for the Web Rotator"
187.            );
188. 
189.            Config.GetManager().SaveSection(conf);
190.        
191.    
192.

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

Hello Trevor,

Please take a look at this post.

Best wishes,
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 27-Oct-2010 00:00

Hi Ivan,


Thank you for your reply. I actually already also built a project based on your example and ran into the same problem of it not appearing.

I just want to double check if it's my code or actually my procedure adding it to Sitefinity that's causing problems (not restarting correctly etc.)

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

Hi Trevor,

I checked the example and it is working fine.  In your code you are not creating any backend pages through the page manager and this is why the module does not appear.

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 29-Oct-2010 00:00

Hi Ivan,

Thank you for your reply. I built a module from your sample and I'm running into the exact same problem. I'm attaching the project as well as the steps I took after I added the reference and built the website:

Project Code: Code

Administration > Settings THEN System > ApplicationModules

Create New

Name: SampleModule
Title: SampleModule
Type: SampleModule.SampleModule
StartupType: OnApplicationStart
Install: Check

Save Changes

Restart IIS site. (Tried rebuilding the site, restarting the PC, stopping and starting IIS... no luck.)

Some where I am missing a step with setting up modules. I would really appreciate it if you could list the steps I should take since I cant see anything different from what I'm doing compared to what is setup in the SDK tutorial.

Posted by Community Admin on 01-Nov-2010 00:00

Hello Trevor,

There is a bug that we introduced in the BETA 2 related to the modules and the Main Menu. The backend pages are created, but they are not visible in the menu. We have fixed the issue, and you will be able to see your module in the navigation in the RC.

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 01-Nov-2010 00:00

Hi Ivan,

Thank you for getting back to me. I'm looking forward to the release of the RC version, luckily just a few more days to go.

This thread is closed