April 02, 2007

Changing Skins via Database (Emergency Procedures)

At one point or another it seems that almost everyone accidentally makes a change to a DNN installation that ends up breaking things. One of these situations that I never considered in the past was the accidental application of a skin with errors. I was contacted by someone today that accidentally applied a skin that caused a null reference exception, this caused the entire site to be unavailable. They couldn't access any pages and couldn't get back to the skin admin pages. Well, this lead me to find a method of resolving the issue via the database. Below I will describe the steps needed to change the skin to a default skin via the database.


As with all other blog postings that relate to DNN database modifications please follow these instructions at your own risk and only use this method as a last resort. Whenever possible you will want to use the DNN interface to perform any changes, however for those times when you are unable to this can be a lifesaver. As always, please ensure that you have performed a backup of your database prior to executing any of the below steps.

Overview of the changes

With the simple script below I will show you how to update the current skin for a specific DNN portal (Both admin and regular views) to the DNN-Horizontal-Blue-Fixed skin. The path values that will be used in this example SHOULD be the same for all DNN versions, however you will want to ensure that the file does exist within the Portals/_Default/ folder of your DNN installation. This procedure involves updating two database records, one for the normal user view and one for the admin view. Before you proceed you must know the portal id of the portal you wish to update. If you are not sure, you should be able to determine the correct PortalId using the information contained within the "Portals" database table.

The Process

For my example situation I will be working with the portal id of 0, and will be applying the DNN-Horizontal-Blue-Fixed skin which was included in the default DNN installation. Below is the script needed to update my portal to this skin. Notice for the updated SkinSrc that the path has a "[G]" before the actual path, this tells DNN that this is a GLOBAL skin and is stored in the Portals/_Default/ folder rather than our actual portal's folder.

Also, note in the were clause that we are updating on when PortalID=0 AND where SkinRoot = 'Skins'.  This where clause ensures that we set the skin value but do not modify the values set for the container as they are also specified in the Skins table.

UPDATE skins
SET skinsrc '[G]Skins/dnn-blue/horizontal menu - fixed width.ascx'
WHERE PortalID 0
AND SkinRoot 'Skins'

When you run the above query it should affect two rows. Now once you have updated the database you have 1 additional step to complete the skin change. Due to the caching methods used by DNN you must restart ASP.NET before the changes will take place. It is typically the easiest to do this by simply adding a space to the end of your web.config file and resaving it. You should now be able to navigate to your DNN portal and see the content with the default DNN Blue skin. You may now specify a different skin or remove the defective one.

tags: DNN, Tutorials, SQL
comments powered by Disqus

Content provided in this blog is provided "AS-IS" and the information should be used at your own discretion.  The thoughts and opinions expressed are the personal thoughts of Mitchel Sellers and do not reflect the opinions of his employer.

Content Copyright

Content in this blog is copyright protected.  Re-publishing on other websites is allowed as long as proper credit and backlink to the article is provided.  Any other re-publishing or distribution of this content is prohibited without written permission from Mitchel Sellers.