Extending DNN by forking an intrinsic DNN provider
Dot Net Nuke (DNN) as a CMS is developed for expansibility and the core framework is designed to make this achievable. This post does discuss extensibility in detail. It is hoped that it will be found beneficial for analysts or technology advisors whom are considering DNN for porting their businesses on DNN for ease of administration.
It is more or less a practice while developing on top of DNN, not to alter the source code often regarded as following,
“DNN’s core will remain un-altered during the course of development for this project”
Then how do you exactly achieve extensibility if you don’t really change the core? DNN heavily utilize the concept of providers from data access to navigation. As a developer or an architect, if you are restricted by an intrinsic feature of DNN, what you can do is to develop on top of existing framework by forking an existing provider.
By forking we mean that you take the source code of that particular provider (since that is redistributable as being open source), duplicate that yet following the standard inheritance chain in set of classes and create a new provider project. Then you simply plug the new provider entry in the web.config file.
Here we will consider a simple case of forking DNN’s sitemap provider. We only want to filter the Urls listed in sitemap of which parent Tab (DNN’s pages are termed tabs) are of type Url. This is pretty simple and will explain the concept of forking.
At the time of this writing the latest version of DNN’s (5.6.2 beta) sitemap provider can be found at,
http://dotnetnuke.codeplex.com/SourceControl/changeset/view/58582#608945
Duplicate this class in your own provider project. To explain that DNN’s default language (VB) doesn’t limit the extensibility during forking process, I have done so in a C# project,
namespace DNN.Providers.SampleSitemapProvider
{
public class TestSitemapProvider : DotNetNuke.Services.Sitemap.SitemapProvider
{
…
The only change we will have to bring in the code of this file to filter the Urls as per our need will be in method,
private SitemapUrl GetPageUrl(TabInfo objTab, string language)
{
…
Just before the line that says,
pageUrl.Priority = GetPriority(objTab);
place a method call,
//Filter Url
if (!CheckParentTabType(objTab))
{
return null;
}
And introduce a private method in the very file,
private bool CheckParentTabType(TabInfo objTab)
{
try
{
if (objTab != null)
{
if (objTab.ParentId != -1)
{
TabController tabController = new TabController();
TabInfo parentTabInfo = tabController.GetTab(objTab.ParentId);
if (parentTabInfo != null)
{
if (parentTabInfo.TabType == TabType.Url)
{
return true;
}
}
}
}
catch (Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
}
return false;
}
That is all. Verify the build output path points to bin folder and bring following change in provider section for sitemap for this new provider to trigger when sitemap.aspx page is requested,
<sitemap defaultProvider="coreSitemapProvider">
<providers>
<clear />
<add name="coreSitemapProvider" type="DotNetNuke.SitemapProviders.CoreSitemapProvider, DotNetNuke.SitemapProviders.CoreSitemapProvider" providerPath="~\Providers\MembershipProviders\Sitemap\CoreSitemapProvider\" />
</providers>
</sitemap>
So we will only have to add a new node in this section as following,
<add name="sampleSitemapProvider" type="DNN.Providers.SampleSitemapProvider.TestSitemapProvider, TKCarsites.Providers.SampleSitemapProvider" providerPath="~\Providers\MembershipProviders\Sitemap\CoreSitemapProvider\" />
And flip the default sitemap entry from
<sitemap defaultProvider="coreSitemapProvider">
to
<sitemap defaultProvider="SampleSitemapProvider">
For our sitemap to take effect. Off course for a production deployment this makes more sense to be performed using manifest file config section. The complete project is attached for quick review.
About Me
Usman ur Rehman Ahmedis known as a software engineer in Lahore, Pakistan. He is renowned for having an abstract understanding of vast range of technological developments such as programming languages, web development, RIA's and documental writing, and is mainly specialized in developmental analysis.
Tags
- windows phone 7 (15)
- DNN (14)
- Dot Net Nuke (13)
- .NET (5)
- c# (5)
- manifest (4)
- Application (3)
- MySql (3)
- Provider (3)
- Sql (3)
- View all 237 tags »
- Sql Server (3)
- Stored Procedure (3)
- visual sutdio (3)
- API (2)
- Data (2)
- Mango (2)
- Module (2)
- Permission (2)
- PhoneTextBlock (2)
- User Control (2)
- Windows (2)
- config (2)
- console (2)
- developer (2)
- dot net (2)
- emulator (2)
- enumeration (2)
- expression blend (2)
- extension (2)
- loop (2)
- network (2)
- phone 7 (2)
- tools (2)
- transparent (2)
- .ascx (1)
- 3g (1)
- 5.6.2 (1)
- 7.1 (1)
- 7.5 (1)
- AJAX (1)
- Activity (1)
- App.xaml (1)
- AppManifest (1)
- ApplicationIcon (1)
- Arabic (1)
- Background.png (1)
- BuildAction (1)
- Connector (1)
- Control Panel (1)
- Core Version (1)
- Data-tier (1)
- DataBound (1)
- Database (1)
- Dependency (1)
- DeviceNetworkInterface (1)
- Directory (1)
- Dynamic (1)
- EVDO (1)
- Encryption (1)
- File (1)
- FileSystemWatcher (1)
- Filter (1)
- Foreign Key (1)
- Function (1)
- GUID (1)
- GetSiteLog (1)
- Hash (1)
- Host Settings (1)
- IIS6 (1)
- IIS7 (1)
- Integrated Mode (1)
- Internet Explorer (1)
- IsolatedStorage (1)
- Java (1)
- Koder (1)
- Linq (1)
- Lists (1)
- Log (1)
- Marketplace (1)
- Membership (1)
- Microsoft (1)
- NavigationCacheMode (1)
- NavigationContext (1)
- NavigationService (1)
- Notify (1)
- OnClientNodeChecked (1)
- PTCL (1)
- Panaroma (1)
- Password (1)
- Properties (1)
- Query String (1)
- ResXResourceReader (1)
- ResolveHostNameAsync (1)
- Right to Left (1)
- SDK (1)
- SEO (1)
- SendKeys (1)
- SendWait (1)
- SharpPCap (1)
- Stream (1)