Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Skins, Themes, ...Skins, Themes, ...changing css file used based on URL parameterchanging css file used based on URL parameter
Previous
 
Next
New Post
8/25/2009 4:23 AM
 

Hi

I have a client that wants the following :

1. Single DNN installation, with multiple portals
2. One of these portals will be a central knowledge base, from which we will pull rss feeds of articles published there into the other portals.

My problem is this - the other portals will have unique identites (even though they are all in the same line of busines, they are independant brokers and want ownership of articles they publish and of their brand). As a result, we want to allow users to search the central knowledge base site from these other portals.

What I want to do, is set the css file that the skin references, based on the url used to access the knowledge base site.

Setup would be as follows :

site1.com, site2.com and site3.com all have a search form that posts the search query to the knowledgebase site (call this know.com for this example).

know.com will have various http aliases, such as site1.know.com, site2.knw.com and site3.know.com

What I want to do is change the css file used by the skin, based on the querystring passed by the search form

eg. a search from site1.com would send a querystring to site1.know.com - something like http://site1.know.com?query=testarticle&sid=1

sid would denote what css file to use.

Can anyone tell me how I would add a script in asp.net like this to my skin.ascx file, so that is changes the css file to site1.css when sid=1, and to site2.css if sid=2 and so on ?

Thanks in advance :)

 

 
New Post
8/25/2009 8:50 AM
 

Hi,

I answered a similar question yesterday.  See http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/-1/threadid/326300/scope/posts/Default.aspx

You will just need to change the part, DotNetNuke.PortalSecurity.IsInRole("MyRole1") to something that evaluates the querystring parameter , in your case, sid.

My advice would be to check that the querystring parameter exists before the if statement and set it to a variable.

Hope this helps.

 

 
New Post
8/25/2009 9:51 AM
 

Hi Robert

I modified your code a little, and have a working model now.

Now all I need to do is figure out how to keep the css file persistent when a user browses through the site, and I am sorted. Any ideas ?

Thanks for the assist so far - its most appreciated :)

Here is the mod I did to your code :

<script runat="server">
    Protected Overrides Sub OnLoad(ByVal e As EventArgs)
        MyBase.OnLoad(e)
       
        Dim tempCSS
       
        tempCSS = Request.QueryString("cssfile")
  
  If tempCSS = "2"  Then
            AttachCustomHeader("<link href='" + SkinPath + "skin2.css' rel='stylesheet' type='text/css' />")
        Else
            AttachCustomHeader("<link href='" + SkinPath + "skin.css' rel='stylesheet' type='text/css' />") 
        End If

    End Sub

    Sub AttachExternalCSS(ByVal CSSPath As String)
        AttachCustomHeader("<link type='text/css' rel='stylesheet' href='" & CSSPath & "' />")
    End Sub
   
    Sub AttachExternalJS(ByVal JSPath As String)
        AttachCustomHeader("<script type='text/javascript' src='" & JSPath & "'></scr" & "ipt>")
    End Sub
   
    Sub AttachCustomHeader(ByVal CustomHeader As String)
        Dim HtmlHead As HtmlHead = Page.FindControl("Head")
        If Not (HtmlHead Is Nothing) Then
            HtmlHead.Controls.Add(New LiteralControl(CustomHeader))
        End If
    End Sub
</script>

 
New Post
8/25/2009 10:49 AM
 

I would not use the querystring at all but the Portal Alias (it does not change):

        Dim sSkin As String = PortalSettings.ActiveTab.FullUrl.Replace("http://", "")
        sSkin = sSkin.Split(".")(0)
        sSkin = sSkin.Split("/")(0)
        sSkin = sSkin & ".css"

or a cleaner solution using RegEx

 

 

 
New Post
8/25/2009 11:29 AM
 

Hi Timo

That would work even better I think. If it was running off the alias, the design would stay consistent while they navigate through the site (which falls apart using the other example with the querystring ...)

So if the incoming alias was http://site1.know.co.za,  it would use site1.css - if the alias was site2.know.co.za it would then use site2.css - thats cool.

However, I am not an advanced programmer at all, and don't quite understand how to relate your code sample above to the other example we have here. Can you perhaps elaborate a bit more ?

Thanks for the help :)

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Skins, Themes, ...Skins, Themes, ...changing css file used based on URL parameterchanging css file used based on URL parameter


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out