Sitefinity intra-site modules: The Unbearable Lightness of Development

Sitefinity intra-site modules: The Unbearable Lightness of Development

December 20, 2007 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

As I have promised in my last post, I have created a Contacts module (previously developed as pluggable module) as an intra-site module. Though, I've said I'll make a post series out of it, creating an intra-site module in Sitefinity is so simple that I can't see how would I span the topic into a series. A single post will do just fine.

I’ve been asked many times is it necessary to use Nolics.Net when developing with Sitefinity and the answer is, of course, no. But as far as I can remember, I don’t think we’ve provided a sample of it anywhere, so I’ve decided NOT to use Nolics.Net in this module… to make things really simple I was using SqlDataSource. That of course doesn’t mean that you can’t use ObjectDataSource or good ol’ SqlDataReader.

The whole project you can download from here. I suggest you do it now because I’ll be referring to the files throughout the post. To illustrate how easy it is to create a new intra-site module, I’ve took the liberty to provide you with a little diagram.

Intra-site module

As the graphic suggests, there is a minimum of four steps that you need to complete in order to create your module. Anything else that you will be doing depends exclusively on the project / module you are working on. These four steps are:

1. Create a folder for your module
2. Create ControlPanel user control
3. Create CommandPanel user control
4. Create Module class

1. Create a folder for your module



Ok, you don’t really need to create a folder for your module. You could have your controls anywhere you please… but it’ll keep things organized if you do. So, as you can see in the project you’ve downloaded, I’ve created a folder ContactsModule in the root folder and that is where I will keep all the module related files.

2. Create ControlPanel user control



Notice that I’ve just said: “user control”. This is one of the biggest differences between pluggable modules and Intra-Site modules. Here, in Intra-site modules, everything is achieved through user controls. Drag-and-drop baby!

I’ve created “Admin” folder inside of my ContactsModule folder to keep all the user controls I’ll be using on the admin side of my modules. You are not required to do that obviously.

The only thing you need to keep in mind with this user control is that it has to implement IControlPanel interface. After you implement the interface, everything else you do is completely up to you. The ContactsModule you’ve downloaded is well commented so I won’t be going into details here.

3. Create CommandPanel user control



This step is very similar to the step 2, except that this time it is CommandPanel user control we are creating and this time we need to implement ICommandPanel interface.

NOTE: You’ll notice that in intra-site module we are implementing interfaces, while in pluggable module we inherit from the base classes. This is of course because user controls need to inherit UserControl class. The implementation is a bit different than in pluggable module, so pay attention to that if you have experience with pluggable modules.

Same as with ControlPanel, after you implement the interface everything else you do is up to you.

4. Create module class



Every intra-site module needs to have a module class that will typically inherit from WebModule class. This class you’ll put in App_Code folder. This is the central class of every module. I’ve commented the code in this class, and you can use this class as a template for your own modules. The parts that need to be modified are rather obvious.

And that’s it…

How to install Contacts intra-site module



Note, you’ll need an already working Sitefinity website.
  • Download the project if you haven’t already
  • Unzip it (good thing I’ve mentioned this, ehh? :)
  • Copy the files from App_Code to the App_Code folder of your already existing Sitefinity website
  • In your database (probably App_Data/Sitefinity.mdf) add the two tables for Contacts module. Those are sample_Contacts and sample_Departments. I’ve provided you with my Sitefinity.mdf file so you can see the schema there or script them from there. Are you missing Nolics yet? If it was Nolics you wouldn’t need to create any tables…
  • Copy ContactsModule folder to the root folder of your already existing Sitefinity website
  • Copy the Sitefinity/Admin/Themes/Default/modules.css to the same place on your already existing website. Alternatively you can simply append the last few styles for the contacts module to your modules.css
  • Make sure you have connection string named “Sitefinity” in your web.config and that it points to the database where you have created the two needed tables. If you don’t you’ll have to modify all SqlDataSource controls in user controls.

Well, I think that’s all. There is really nothing else to explain because everything else is just a familiar ASP.NET stuff. Let me know if you encounter problems or if you have questions.

Sometime next week I’ll publish this module in VB.NET as well… and then the video!

[UPDATE: Apparently I have messed up something with the database file - see comments below - so I am posting the zip of database again. You can download it from here. ]

progress-logo

The Progress Team

View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments
Comments are disabled in preview mode.
Topics
 
 
Latest Stories in
Your Inbox
Subscribe
More From Progress
New_Mobile_Dev_Ebook_Progress_Website_Thumbail
The New Mobile Development Landscape
Download Whitepaper
 
IDC Spotlight Sitefinity Thumbnail
Choosing the Right Digital Experience Platform to Improve Business Outcomes
Download Whitepaper
 
TheFastestWayToBuildMobileAppsArtboard-2
The Fastest Way to Build Mobile Apps With Cloud Data
Watch Webinar