Sign In  |  Register
 
 
DotNetNuke Support Forums
PortalAlias SmartSkin™ Switcher
Last Post 26 May 2009 05:35 PM by jerops. 14 Replies.
Printer Friendly
Sort:
PrevPrevNextNext
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
Administrator
Veteran Member
Veteran Member
Send Private Message
Posts:3667
Avatar

--
13 Apr 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
New Member
New Member
Send Private Message
Posts:15

--
28 Aug 2007 02: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
Administrator
Veteran Member
Veteran Member
Send Private Message
Posts:3667
Avatar

--
11 Sep 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
New Member
New Member
Send Private Message
Posts:3

--
21 Sep 2007 09: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
New Member
New Member
Send Private Message
Posts:3

--
21 Sep 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
Administrator
Veteran Member
Veteran Member
Send Private Message
Posts:3667
Avatar

--
24 Sep 2007 04: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
New Member
New Member
Send Private Message
Posts:34

--
28 Oct 2007 06: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
New Member
New Member
Send Private Message
Posts:34

--
28 Oct 2007 06: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



John Mitchell
Administrator
Veteran Member
Veteran Member
Send Private Message
Posts:3667
Avatar

--
29 Oct 2007 03:41 PM  

Hi Nina,

I have attached a Role Based SmartSkin™ Switcher.

 


Attachment: RoleSwitcher.zip

arifshah
New Member
New Member
Send Private Message
Posts:1

--
14 Nov 2007 09: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
Administrator
Veteran Member
Veteran Member
Send Private Message
Posts:3667
Avatar

--
14 Nov 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



mcselasvegas
New Member
New Member
Send Private Message
Posts:1

--
28 Feb 2009 01:45 PM  
Hi John,

I am using dnn 4.9.2 and get the following error if I try to use the Skin Switcher...

Could Not Load Skin: /Portals/0/Skins/SkinSwitch/SkinSwitcher.ascx Error: Unable to cast object of type 'ASP.portals_0_skins_skinswitch_skinswitcher_ascx' to type 'DotNetNuke.UI.Skins.Skin'

Does your code not work with this version? The Skin engine might have been rewritten?
Do you have a solution for later dnn versions?

Thank you,
Oliver


John Mitchell
Administrator
Veteran Member
Veteran Member
Send Private Message
Posts:3667
Avatar

--
02 Mar 2009 10:36 PM  
From the error, it does appear that they have changed the Skin engine to require a skin to be inherited from DotNetNuke.UI.Skins.Skin.
Try adding this code to the top of the switcher:

<%@ Control language="vb"  AutoEventWireup="false" 
          Explicit="True" Inherits="DotNetNuke.UI.Skins.Skin" %>


stretow
New Member
New Member
Send Private Message
Posts:1

--
25 May 2009 06:51 AM  
edit

has done

Thanks


jerops
New Member
New Member
Send Private Message
Posts:52

--
26 May 2009 05:35 PM  
Hi John,

I'm trying to use your roleswitcher.aspx code on a minimalist 2.0 skin and it doesn't appear to be picking up the CSS file. Each Minimalist ascx skin file has an associated css file named the same as the ascx file in order for it work...I see above in the forum you have talked about linking the CSS skin
. How can I incorporate that into your RoleSwitcher.aspx code? Can I put that right after the skin = "MySkin.ascx" line?

Thanks for help, I really appreciate it.
Jerry


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


Active Forums 4.1
Visit our Store for great DotNetNuke Modules and Skins
DotNetNuke CSS Menu 3.3.6 (single use)

Item codeCSSNM33SU
AuthorJohn Mitchell
Base Price$39.00
Product Information 
DotNetNuke CSS NavMenu 3.3.6 (Developers)

Item codeCSSNM33DEV
Base Price$149.00
Product Information 
DotNetNuke Performance Caching & Compression - PageBlaster 3.3.2 - Professional Edition

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

AuthorNina Meiers
Price$49.00
Product Information 
XDAmarina Standard

AuthorNina Meiers
Price$49.00
Product Information