You are here:   Home
  |  Login
DotNetNuke Core Team
Microsoft MVP
 Bookmark this article!
delicious.com delicious.com
digg digg
technorati technorati
reddit reddit
stumbleupon stumbleupon
facebook facebook
google bookmarks google bookmarks
yahoo bookmarks yahoo bookmarks
slashdot slashdot
live live
twitter twitter
DotNetKicks DotNetKicks

Tags

  1. 1 items are tagged with Admin settings
  2. 1 items are tagged with AJAX Extensions
  3. 1 items are tagged with ASP.NET
  4. 2 items are tagged with BBeyond
  5. 1 items are tagged with Caching
  6. 1 items are tagged with Cambrian
  7. 1 items are tagged with CBO
  8. 2 items are tagged with Codeplex
  9. 1 items are tagged with debugging
  10. 1 items are tagged with DotNetNuke
  11. 2 items are tagged with DotNetNuke 5
  12. 1 items are tagged with email validation
  13. 1 items are tagged with Google
  14. 1 items are tagged with IBaseEntity
  15. 2 items are tagged with IdentitySwitcher
  16. 1 items are tagged with IHydratable
  17. 1 items are tagged with Inline Skin Object
  18. 2 items are tagged with Installation
  19. 1 items are tagged with Installer
  20. 1 items are tagged with intellisense
  21. 1 items are tagged with IPropertyAccess
  22. 1 items are tagged with Language
  23. 1 items are tagged with Manifest
  24. 1 items are tagged with moving
  25. 1 items are tagged with OpenForce
  26. 1 items are tagged with Permissions
  27. 1 items are tagged with Profile Properties
  28. 1 items are tagged with PropertyEditorControl
  29. 1 items are tagged with recent projects
  30. 1 items are tagged with regex
  31. 1 items are tagged with Sample Module
  32. 1 items are tagged with Search Results
  33. 2 items are tagged with Skin Object
  34. 1 items are tagged with Skinning
  35. 6 items are tagged with SQL
  36. 1 items are tagged with SQL Server
  37. 1 items are tagged with SQL Server 2008
  38. 1 items are tagged with Table Functions
  39. 2 items are tagged with TellCo
  40. 1 items are tagged with TokenReplace
  41. 2 items are tagged with Too Good to be True
  42. 1 items are tagged with Twitter
  43. 2 items are tagged with UPC
  44. 2 items are tagged with Upgrading
  45. 1 items are tagged with Users
  46. 2 items are tagged with visual studio
  47. 1 items are tagged with Visual Studio 2008

My Twitter Feed...

Fri, 05 Mar 2010 09:25:30 +0100

erikvb: @schotman you probably ran into this already? http://www.simonblog.com/2008/11/14/qr-code-reader-for-iphone-barcodes-zxing/

Wed, 03 Mar 2010 16:22:05 +0100

erikvb: @CuongDang @WillStrohl btw: another reason to use #mixero: it has a global filter

Wed, 03 Mar 2010 15:57:33 +0100

erikvb: @WillStrohl @CuongDang #foursuare yep.. just look at http://pleaserobme.com

Tue, 02 Mar 2010 11:39:20 +0100

erikvb: ok this is weird...RT @cnnbrk: Chile quake might have shortened days on Earth http://on.cnn.com/b3V8Mq

Sat, 27 Feb 2010 11:25:22 +0100

erikvb: @aafvstam its almost 2012 :)

Sat, 27 Feb 2010 11:24:44 +0100

erikvb: RT @superska: Did I mention we (@erikvb @pdonker @superska) kicked off the new Dutch spoken DNN Usergroup today? http://www.dnngg.nl #mv ...

Fri, 26 Feb 2010 22:23:00 +0100

erikvb: fiasco

Fri, 26 Feb 2010 22:19:17 +0100

erikvb: @TimoBreumelhof #Sauerbreij fat chance.. niet zolang mart smeets de dienst uitmaakt

Fri, 26 Feb 2010 22:09:39 +0100

erikvb: first alpine gold medal for the Netherlands #olympics #van2010

Fri, 26 Feb 2010 22:07:15 +0100

erikvb: yesss.. gold for nicolien!

Creating a DotNetNuke inline skinobject

Last Updated 10/26/2008
By: Erik van Ballegoij

Last week I was asked to come up with a way to use the Page Icon in DotNetNuke as a source for a multi lingual enabled image on a page. Although this could have been done by creating a skinobject, I decided to pull this one off by creating an "inline" skinobject.. by lack of a better term.

Before we start, there are a few things we need to keep in mind:

  • because the page icon is selected through the DNN interface, we need one location that is used as default location, without locale
  • DNN Admin pages use page icons, so we need to exclude those (as they are not located in the portal root)

First we start with adding a server side script block, with an asp.net PageLoad eventhandler, to our skin. This is done in the .ascx file of the skin, location in the file does not matter. Like this:

   1:  <script runat="server">
   2:      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   3:      End Sub
   4:  </script>

 

next, we will use a new literal control in the skin to add the code for our image to, like this:

 

   1:  <asp:Literal ID="litMyImage" runat="server" />

 

The code in page_load will look like this. Don't worry, i will explain

 

   1:  <script runat="server">
   2:      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   3:          If (Not String.IsNullOrEmpty(PortalSettings.ActiveTab.IconFile)) Then
   4:              If Not PortalSettings.ActiveTab.IsAdminTab And Not PortalSettings.ActiveTab.IsSuperTab Then              
   5:                  Dim Locale As String = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName
   6:                  Dim myImageFile As String = ""
   7:                  If Locale = "nl" Then
   8:                      myImageFile = PortalSettings.ActiveTab.IconFile
   9:                  Else
  10:                      Dim myFile As String = PortalSettings.ActiveTab.IconFile.Substring(PortalSettings.ActiveTab.IconFile.LastIndexOf("/") + 1)
  11:                      Dim myFolder As String = ""
  12:                      If PortalSettings.ActiveTab.IconFile.LastIndexOf("/") > 0 Then
  13:                          myFolder = PortalSettings.ActiveTab.IconFile.Substring(0, PortalSettings.ActiveTab.IconFile.LastIndexOf("/"))
  14:                          myImageFile = String.Format("{0}/{1}/{2}", myFolder, Locale, myFile)
  15:                      Else
  16:                          myImageFile = String.Format("{0}/{1}", Locale, myFile)
  17:                          
  18:                      End If
  19:                  End If
  20:                  litMyImage.Text = String.Format("<img alt=""{0}"" style=""width:140px"" src=""{1}{2}"" />", PortalSettings.ActiveTab.Title, PortalSettings.HomeDirectory, myImageFile)
  21:              End If
  22:          Else
  23:              litMyImage.Visible = False
  24:          End If
  25:      End Sub
  26:  </script>

 

First we start off by checking for the existence of the iconfile:

 

   3:          If (Not String.IsNullOrEmpty(PortalSettings.ActiveTab.IconFile)) Then

 

Next we check whether the page is an admin tab:

 

   4:              If Not PortalSettings.ActiveTab.IsAdminTab And Not PortalSettings.ActiveTab.IsSuperTab Then              

 

Next, we get the 2-letter ISO code for the current culture:

 

   5:                  Dim Locale As String = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName

 

Next, for the default locale (in this example the default is nl-NL), we use the iconfile as available in DotNetNuke:

 

   7:                  If Locale = "nl" Then
   8:                      myImageFile = PortalSettings.ActiveTab.IconFile

 

For all other locales, we need to do some calculating with the path information. What I'd like to do is to use this for the default locale: [portalroot]/[somepath]/iconfile.ext, and this for all other locales: [portalroot]/[somepath]/[2-letterisocode]/iconfile.ext. We need to do some cutting and pasting in the original path that DNN reports for the icon file:

 

  10:                      Dim myFile As String = PortalSettings.ActiveTab.IconFile.Substring(PortalSettings.ActiveTab.IconFile.LastIndexOf("/") + 1)
  11:                      Dim myFolder As String = ""
  12:                      If PortalSettings.ActiveTab.IconFile.LastIndexOf("/") > 0 Then
  13:                          myFolder = PortalSettings.ActiveTab.IconFile.Substring(0, PortalSettings.ActiveTab.IconFile.LastIndexOf("/"))
  14:                          myImageFile = String.Format("{0}/{1}/{2}", myFolder, Locale, myFile)
  15:                      Else
  16:                          myImageFile = String.Format("{0}/{1}", Locale, myFile)
  17:                          
  18:                      End If

 

Finally, we assign the value of the literal control with our image tag:

 

  20:                  litMyImage.Text = String.Format("<img alt=""{0}"" style=""width:140px"" src=""{1}{2}"" />", PortalSettings.ActiveTab.Title, PortalSettings.HomeDirectory, myImageFile)

I would agree that this is some work, however, we now have the option of a multilanguage page icon in our page. Of course a skinobject would also have worked, but the nice thing about this solution is that it will just work in this particular skin. Also, you can just package the skin and install it on a different installation and it will still work. In a sense you now have the option to include a skinobject with your skin.

Of course... you will be able to do that with DNN 5.0 anyway, but in a way this brings a great DNN 5.0 feature to DNN 4.x

The code in this blog was tested on DNN 4.9.0

Rate this:
Recent Comments

I notice your example plugged in .net code directly to the page. Is it possible to create an aspx/ascx page and include it in the skin and upload a vb/cs codebehind up with your skin so that items that are programatically designed(eg a custom menu) can be embedded to your skin?

Posted By: Bart Chavez on 10/18/2008
Yes thats quite possible. Remember that a skinobject is just a user control, so you can include your own usercontrol (ascx file) in your skin package and reference that from the skin. I have not tested that, but you probably won't be able to use separate code behind files as those file types are not allowed by DNN. I will do an example of how that works in one of my next blogs.
Posted By: Erik van Ballegoij on 10/19/2008
Very cool walk-through. Thanks!
Posted By: Will Strohl on 12/09/2008
Upon further inspection, dnn appends every server control with an explicit short name in Default.aspx. Therefore, if my control had of "myControl" it would be changed to something like "dnn_myControl"... How were you able to get around this? Thanks.
Posted By: David S on 10/29/2009
I have tried adding a literal to my skin and adding a page_load event to change the text of that literal, but it does not work. Am I missing something? Using DNN 5.
Posted By: David S on 10/29/2009

Powered By

DotNetNuke Powered! This site is proudly powered by DotNetNuke.

 

(Advertisements)

My other blogs

Thu, 21 May 2009 18:41:00 +0200

Fri, 01 May 2009 14:57:00 +0200

Wed, 29 Apr 2009 16:11:00 +0200

Mon, 27 Apr 2009 20:33:05 +0200

Wed, 21 Jan 2009 20:13:00 +0100

Mon, 05 Jan 2009 23:00:00 +0100

Fri, 05 Dec 2008 16:45:08 +0100

Sun, 05 Oct 2008 22:23:00 +0200

Wed, 17 Sep 2008 14:07:00 +0200

Sun, 24 Aug 2008 21:23:00 +0200