More in this section

Forums / Developing with Sitefinity / Implementation advice needed

Implementation advice needed

5 posts, 0 answered
  1. Nigel
    Nigel avatar
    38 posts
    Registered:
    01 Dec 2004
    16 Apr 2008
    Link to this post
    Hello!

    I need to create a "recipe" book in SiteFinity. Most of the functionality I need is already in the Blogs module (categories, tags, comments, etc...). However, each recipe post will also need a view count, a rating system, and a couple of additional text fields + a recipe image.

    From looking at the documentation, I have assumed that I need to create a custom module. However, since most of the functionality is already in Blogs, should I  just extend the Blog module? If so, can you give me some pointers on how I should get started -  what needs to be implemented and/or inherited, etc...?

    Thanks.
  2. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    17 Apr 2008
    Link to this post
    Hello Nigel Kennedy,

    Indeed, you are on a good track. However, Blogs module inherits from Generic Content module and all the functionalities you've been writing about (categories, comments, tags...) are actually parts of Generic Content module and Blogs module is only reusing them. I know this may sound a bit strange, because Generic Content module does not have the interface for any of the mentioned features, but it's just the UI that is not there.

    So here is my advice: you should develop a new module, inherit Generic Content module and then implement any needed functionality as you see fit. Here is a blog post explaining how to do exactly that, and you can also download the sample code: Sample Events Module Building a Pluggable Module Based on Generic Content

    Please note that the Sample.Events module in the post is NOT the events module that we have released in Sitefinity 3.2.

    Let me know if you have any additional questions.

    All the best,
    Ivan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Nigel
    Nigel avatar
    38 posts
    Registered:
    01 Dec 2004
    18 Apr 2008
    Link to this post
    Thanks Ivan. I've been studying the recommended download and also looking at the Blogs module - as it's pretty close to what I need. I have a slight problem in that my C# is only passable. I am having trouble understanding the shared constructor for the blog manager. Could you possibly translate and explain what exactly is going on?

    Sorry to be a pain! Here's the code:

    Shared Sub New() 
            Dim element As GenericContentElement 
            For Each element In ConfigHelper.Handler.GenericContentProviders 
                BlogManager.contentSettings.Add(element.ProviderName, element) 
                Dim execute As IEventExecute = TryCast(ContentManager.Providers.Item(element.ProviderName),IEventExecute) 
                Dim base2 As ContentProviderBase = DirectCast(execute, ContentProviderBase) 
                If (base2.GetVariable("BlogPostsCount") <> "True") Then 
                    base2.BulkUpdate(Of IBlog)(DirectCast(execute, IBlogProvider).GetBlogs, Function (ByVal blog As IBlog)  
                    End Function) 
                    base2.SetVariable("BlogPostsCount""True"
                End If 
                If (Not execute Is Nothing) Then 
                    AddHandler execute.Executed, New EventHandler(Of ExecutedEventArgs)(AddressOf BlogManager.ContentProvider_Executed) 
                End If 
            Next 
        End Sub 
     

    I am particularly stumped by the lines first if block.
  4. Nigel
    Nigel avatar
    38 posts
    Registered:
    01 Dec 2004
    18 Apr 2008
    Link to this post
    OOPS! I should have posted this code:

     static BlogManager() 
        { 
            foreach (GenericContentElement element in ConfigHelper.Handler.GenericContentProviders) 
            { 
                contentSettings.Add(element.ProviderName, element); 
                IEventExecute execute = ContentManager.Providers[element.ProviderName] as IEventExecute; 
                ContentProviderBase base2 = (ContentProviderBase) execute; 
                if (base2.GetVariable("BlogPostsCount") != "True"
                { 
                    base2.BulkUpdate<IBlog>(((IBlogProvider) execute).GetBlogs(), delegate (IBlog blog) { 
                    }); 
                    base2.SetVariable("BlogPostsCount""True"); 
                } 
                if (execute != null
                { 
                    execute.Executed += new EventHandler<ExecutedEventArgs>(BlogManager.ContentProvider_Executed); 
                } 
            } 
        } 
     

  5. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    18 Apr 2008
    Link to this post
    Hi Nigel Kennedy,

    You can safely ignore that constructor, because the code executed there takes care of some unique blogs internal functionality.

    The constructor for your module can look like this:

    static BlogManager()  
    {  
       foreach (GenericContentElement element in ConfigHelper.Handler.GenericContentProviders)  
       {  
          contentSettings.Add(element.ProviderName, element);  
       }  

    Because Sitefinity is supporting multiple providers in its modules, this constructor simply loops through all the providers for the current module and adds it to the static contentSettings field. This way, when you work with the data later on, you are able to create a new instance of BlogManager class and specify with which provider you are going to work (e.g. one provider can store blogs data in SQL database, another provider can store blogs data into an XML file, and so on).

    Sitefinity is built on top of the standard ASP.NET 2.0 provider model, so understanding that concept would help you a great deal when developing for Sitefinity. Here is an article where you can find more about it:

    http://msdn2.microsoft.com/en-us/library/aa479030.aspx

     
    Sincerely yours,
    Ivan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
5 posts, 0 answered