Sign In  |  Register
 
 DotNetNuke Powered!
DotNetNuke Support Forums

PortalAlias SmartSkin™ Switcher

Rate this topic:

Please Register to post a reply.
Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.

AuthorMessages
John Mitchell
Posts:3353



04/13/2007 11:14 AM  

Here is a way to dynamically load a skin based on the portal alias used to access the site.

All you need is the following code pasted into a file by itself. Then you can name it something like "PortalAliasSwitcher.ascx" and put it in a skin folder along with the skins that you want it to load based on the Urls. Then go in and assign this file to the page, site, or host settings like you would normally do an individual skin.

<%@ Control language="vb" AutoEventWireup="false" Explicit="True" %>

<asp:placeholderid="SkinPlaceholder"runat="server"/>

<scriptrunat="server">
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    '**  Skincovered.com Portal Alias based skin switcher
    '
**  Switches the skin depending on the Url used to access the site
    '**  Select this skin (PortalAliasSwitcher) as would any other skin in DotNetNuke
    '
** The code below will load a skin from the same folder depending on the Url
        Dim skin As String = ""
        Select CType(HttpContext.Current.Items("PortalSettings"),PortalSettings).PortalAlias.HTTPAlias.ToLower()
            Case "hr.mydomain.com":
                skin = "HumanResources.ascx"
            Case "it.mydomain.com":
                skin = "InformationServices.ascx"
            Case Else:
            'this skin will be loaded if no matches were made to the portal aliases above
                skin = "default.ascx"
        End Select
       
        '
this line loads the actual skin.
        SkinPlaceholder.Controls.Add(LoadControl(skin))
    End Sub
<script>

dschaening
Posts:15



08/28/2007 2:03 PM  

This is a great feature...Any Idea on how I could handle this with a wildcard? 

say  *.mydomain.com is skin A

and *.myotherdomain is skin B?

John Mitchell
Posts:3353



09/11/2007 10:38 PM  

I'm sorry I missed this question earlier.

For getting all the hosts on one domain you could just see if the domain name is in the Url.
Something like:

If Request.Url.Host.IndexOf("mydomain.com") > -1 Then
   skin = "mydomain.ascx"
ElseIf Request.Url.Host.IndexOf("myotherdomain.com") > -1 Then
   skin = "myotherdomain.ascx"
End If

psidrum
Posts:3



09/21/2007 9:42 PM  
Hello, i tried this but i get this error

An error has occurred.
DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.UI.Skins.Skin.Page_Init(Object sender, EventArgs e) at System.Web.UI.Control.OnInit(EventArgs e) at System.Web.UI.UserControl.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at ASP.portals_14_skins_7893_sp002_blue_portalaliasswitcher_ascx.Page_Load(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---

Do you know whats wrong with it? Im using DNN 4.5.1
psidrum
Posts:3



09/21/2007 10:07 PM  
THe code seems to work but it gives me an error when i am logged in as Admin or Host...But if i log out the skin seems to work, but login, the skin does not work. How can i fix this problem?
John Mitchell
Posts:3353



09/24/2007 4:35 PM  

It may be that you need to add a ControlPanel container to your skin. In the actual skin(s) that you are switching to, make sure that there is a line like this:

<divid="ControlPanel"runat="server"></div>

Also, if you want to link to a specific CSS file for the skin that you are switching to the easiest way is to put the css link directly in the skin like this:

<linkrel="stylesheet"type="text/css"href='<%= Page.ResolveUrl("black_full.css") %>'/>
nina
Posts:41



10/28/2007 6:33 AM  

Another challenge for you John - I've tried to do something one way and then another but not able to get the exact results- I then thought a skin by role might be the answer...

What I have is a site where tehre are three products being offered for sale (there might be more but you'll get the idea... )

I tried to add images with link based on role but I wanted to be upselling to these people, and not show the products if they have already bought it.

EG.. I'm a registered user but bought nothing - so the idea is to show products 1, 2 & 3

But if I've bought product 1, I'd like to be able to upsell 2 & 3, but not show product 1 since they have bought it.

If I've bought product 2, I'd like to upsell to product 3, but not show products 1 & 2, since they have  bought them, and of course if they have bought product 3, dont' want to show any.

I tried various methods of trying to hide one thing from another but coudn't work out the roles, so thought that the skin based on role would be ideal, as I'd just have these items displayed in the montage, but I then tried to jiggle the code around, and of course - was hugely... BAD at it..

So, is my thought going down the path?  I thought the skin switcher features were so good, I could work with it.

Thanks

Nina


Nina

http://www.xd.com.au
http://www.skincovered.com

....Make sure you last words are sweet.. you never know when you have to eat them...
nina
Posts:41



10/28/2007 6:36 AM  

OH and I forgot to mention - that each of these skins has a role attached - as when you purchase the product you get assigned a role - I realise that is an important feature or otherwise how would you get it to work in the first place.

 

Nina


Nina

http://www.xd.com.au
http://www.skincovered.com

....Make sure you last words are sweet.. you never know when you have to eat them...
John Mitchell
Posts:3353



10/29/2007 3:41 PM  

Hi Nina,

I have attached a Role Based SmartSkin™ Switcher.

 


Attachment: RoleSwitcher.zip

arifshah
Posts:1



11/14/2007 9:52 AM  
Hi John,

I am looking for options to apply a Low Graphics version on my site. From what I understand, it could be achieved by switching skin to NoSkin.ascx user control. But I would need to do that by clicking on my default page skin to switch to Low Graphics and switch back to the skin applied on the page by clicking on another link on the Low Graphics skin.

Essentially its skin switching by link clicks rather than based on portal alias or role.

Any advice would be great help.

Regards
Arif Shah
John Mitchell
Posts:3353



11/14/2007 11:34 AM  

Hi Arif,

You can switch skins using the querystring by passing it with the SkinSrc parameter.

If you go into Site Settings or Page Settings and click on Preview button for a skin then you can see the format which is basically like this

[G]/Skins/Skincovered_Feb/Login

Which means use a host level skin [G] in the /Skins/Skincovered_Feb folder called Login.ascx

If the Skin was at the portal level it would be [L] instead of [G]

http://www.snapsis.com?tabid=1&SkinSrc=%5bL%5dSkins%2fSkincovered_Feb%2flogin

Please Register to post a reply.
Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.

Forums >DotNetNuke Support >Tips-And-Tricks > PortalAlias SmartSkin™ Switcher



ActiveForums 3.7
Visit our Store for great DotNetNuke Modules and Skins
DNNMasters Sitemap/Google Sitemap 3.0

Item codeSM3-01
Price$29.00
Product Information 
DotNetNuke CSS NavMenu 3.3 (Developers)

Item codeCSSNM33DEV
Base Price$149.00
Product Information 
Snapsis PageBlaster 3.3.2 for DotNetNuke - Professional Edition

AuthorJohn Mitchell
Base Price$79.00
Product Information 
XDAkuna (Web 2.0 CSS XHTML Skin)

Item codeXDAkuna
AuthorNina Meiers
Price$49.00
Product Information