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

Forums / Developing with Sitefinity / Custom module for a link collection

Custom module for a link collection

18 posts, 0 answered
  1. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    26 Jun 2009
    Link to this post
    My company has decided to move from the helpdesk that i wrote for them to a sitefinity based one. One section of the helpdesk is FYI, which is basically just a collection of links that are specific to certain things, such as states.

    So basically I need to create a module that will allow me to add sections (states, for example) then be able to add links to these sections, and finally output them neatly onto a page.

    Any suggestions/pointers would be awesome. I am good with VB.NET, but not too savvy with C# just yet, so this will be a good learning experience for me.

    Cheers,
    anders
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    26 Jun 2009
    Link to this post
    Hello andersleet,

    I suggest that you should develop a Generic Content based module or override one of the existing ones  - like generic content module. You can add custom view and logic depending on your tasks. For the states/links you can create several metakeys and use them. You can create content view based control with custom designer. This will allow you to control which states/links will be visible. By using the metakeys your data will be persisted to the database automatically and this will save you time for developing custom data provider with nolics.

    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.
  3. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    29 Jun 2009
    Link to this post
    Hi Ivan,

    I do not follow what you are saying regarding metakeys. Can you give me an example?

    Thanks!
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    29 Jun 2009
    Link to this post
    Hi andersleet,

    Generic content modules support metafields. This fields are used to store metadata for a generic content based provider. The metadata can use the following types:

    ShortText,  LongText, DateTime, Integer,  FloatingPoint, Boolean, Guid, Binary.

    So basically I need to create a module that will allow me to add sections (states, for example) then be able to add links to these sections, and finally output them neatly onto a page.

    The value from the metadata is persisted to the database through nolics. For your module you can add several metafileds that will be responsible for the sections you want to have and related links. Then to show the value of the metakeys you can modify presentation mode templates for the control that will display information for your custom module. Good example is Events module - there you have several default metafields as Publication and Expiration date, Contact Email , Contact Name , Category, Contact Web , Contact Cell , Contact Phone, Country  etc. All this metafields are displayed on the front end by EventsView control. 

    You can gather more information about Metafields form our UserManual, section Customizing Modules
    Adding Custom Meta Fields
    .
    As for the module architecture, please check our TOC. Another useful resource is Sitefinity Developers Manual.

    Let is know if there is anything else that we can do for you.

    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.
  5. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    02 Jul 2009
    Link to this post
    Hey Ivan,

    I have gotten my custom links collection module completed! I have the back end (administrative side) all taken care of, now I need to create a control to access and display the data. Where can I get some information on this? I thought I looked through the blog posts and video tutorials completely and all I've seen so far is how to create a module OR control, not a control that utilizes a module.

    Thanks again for being so helpful,
    anders
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    02 Jul 2009
    Link to this post
    Hello andersleet,

    You should have a class, say ModuleViewToolBox that inherits from ToolboxItem. In this class you should have a new instance of your ModuleViewToolBox  class and sets DisplayName and Description properties for the control.

     public ModuleViewToolboxItem() 
                : base(typeof(ModulePublicView)) 
            { 
                base.DisplayName = Messages.ModulePublicView_DisplayName; 
                base.Description = Messages.ModulePublicView_Description; 
            } 


    Here is a sample ContentView based control

    using System; 
    using Telerik.Cms.Engine.WebControls; 
     
        [Telerik.Framework.Web.Design.ControlDesigner("Telerik.Samples.Modules.WebControls.Admin.Module.CustomDesigner")] 
        public class ModulePublicView : ContentView 
        { 
     
            public override Type LocalizationAssemblyInfo 
            { 
                get 
                { 
                    return this.GetType(); 
                } 
                set 
                { 
                    base.LocalizationAssemblyInfo = value; 
                } 
            } 
     
            public override Type AssemblyInfo 
            { 
                get 
                { 
                    return this.GetType(); 
                } 
                set 
                { 
                    base.AssemblyInfo = value; 
                } 
            } 
     
           
            public override string ProviderName 
            { 
                get 
                { 
                    object obj = ViewState["ProviderName"]; 
                    if(obj != null
                        return (string) obj; 
                    return ModuleManager.DefaultContentProvider; 
                } 
                set 
                { 
     
                   this.ViewState["ProviderName"] = value; 
                } 
            } 
     
        } 
     
     

    Then you need to create embedded template for your control.

    Kind 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. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    02 Jul 2009
    Link to this post
    Thanks Ivan,

    In your first code snippet, where is the ModulePublicView coming from?

    Regards,
    anders
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    03 Jul 2009
    Link to this post
    Hello andersleet,

    It comes from the second code snippet where we are creating the custom control that inherits from content view  public class ModulePublicView : ContentView

    The same approach is used for all ContentView based controls - NewsView, BlogPosts, EventsView etc.

    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.
  9. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    03 Jul 2009
    Link to this post
    Ahh yes, I see that now. I must have missed it yesterday.

    One more thing (hopefully): Is the second snippet a custom class or a user control?
  10. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    03 Jul 2009
    Link to this post
    Sorry, what I meant to ask was I am getting an intellisense error (the name 'ModuleManager' does not exist in the current context) in visual studio here on line 6 (specifically ModuleManager):

    1  get   
    2  {   
    3       object obj = ViewState["ProviderName"];   
    4       if(obj != null)   
    5            return (string) obj;   
    6       return ModuleManager.DefaultContentProvider;   
    7  } 

    What should I be putting there instead?

    Thanks,
    anders
  11. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    08 Jul 2009
    Link to this post
    Hi andersleet,

    The code of this line should return the name of the default provider, with which the control will be initialized. I am not sure what is wrong in the implementation, and should take a look at the whole project. You can specify any provider there though, for example:
    object obj = ViewState["ProviderName"];    
              if(obj != null)    
                   return (string) obj;    
              return "Your_Custom_Provider"  

    or

    return "Generic_Content".

    Kind regards,
    Georgi
    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. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    08 Jul 2009
    Link to this post
    So if my module is called 'GSFyi', I should put that instead of "Your_Custom_Provider"? Sorry, I am still trying to grasp all this :P

    Regards,
    anders
  13. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    08 Jul 2009
    Link to this post
    Hello andersleet,

    Every module has a provider defined in the web.config file. For example, take a look at the News module definition. You will notice the following:
    <news defaultGenericProvider="News"
          <genericContentProviders> 
            <add providerName="News" publicationDateField="Publication_Date" 
    .... 

    You should have the same statement for your module in the web.config file. Then you initialize the control with the provider name you defined for your module.

    Kind regards,
    Georgi
    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.
  14. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    08 Jul 2009
    Link to this post
    Is there a resource somewhere on your site that can help me with the web.config? I see all those other parameters in the different providers and I would like to know what it all means.

    In the meantime, is it ok to do this?

            <gsfyi defaultGenericProvider="Generic_Content"
                <genericContentProviders> 
                    <add name="Generic_Content" urlRewriteFormat="[Publication_Date]/[Name].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="True" defaultMetaField="Name" securityProviderName="" allowLocalization="False" allowVersioning="True" allowWorkflow="False" allowComments="false" commentsModeration="true" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data"/> 
                </genericContentProviders> 
            </gsfyi> 


    Thanks,
    anders
  15. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    08 Jul 2009
    Link to this post
    Hello andersleet,

    You should also have a section name added for your module, otherwise Sitefinity will not know what <gsfyi is. Please take a look at Products Module: Simple Implementation, and more precisely to step 4 at the bottom.

    Greetings,
    Georgi
    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.
  16. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    08 Jul 2009
    Link to this post
    Ok thanks for the link. In this code, what will I be putting in place of the type "Telerik.Samples..."?

    <section name="products" type="Telerik.Samples.Products.Configuration.SectionHandler, Telerik.Samples.Products" requirePermission="false" /> 

  17. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    08 Jul 2009
    Link to this post
    My module is not compiled into a DLL. Is it easy to convert an intra-site module into a pluggable module?

    Regards,
    anders
  18. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    13 Jul 2009
    Link to this post
    Hi andersleet,

    Well, I am not able to tell you the certain steps, but yes, there are some changes that you should do. You should move your classes in a new project, and add the Sitefinity binaries as references. Still, I believe the examples should be able to provide you with the help you need.

    Regards,
    Georgi
    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.
Register for webinar
18 posts, 0 answered