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

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsSkinsSkinsStyle.ascxStyle.ascx
Previous
 
Next
New Post
1/8/2009 4:51 AM
 

Well since I can't create a new issue on the bug tracker. I thought I'll add it here. I have updated the Style.ascx.vb to allow for a media property on the stylesheet.

 

'
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2008
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'
Imports System.IO
Imports DotNetNuke.UI.Skins
Imports DotNetNuke.Services.Tokens

Namespace DotNetNuke.UI.Skins.Controls

    Partial Class Styles
        Inherits UI.Skins.SkinObjectBase

#Region "Fields"

        Private _condition As String
        Private _isFirst As Boolean = False
        Private _name As String
        Private _src As String
        Private _useSkinPath As Boolean = True
        Private _media As String
#End Region

#Region "Properties"
        Public Property Condition() As String
            Get
                Return _condition
            End Get
            Set(ByVal Value As String)
                _condition = Value
            End Set
        End Property

        Public Property IsFirst() As Boolean
            Get
                Return _isFirst
            End Get
            Set(ByVal Value As Boolean)
                _isFirst = Value
            End Set
        End Property

        Public Property Name() As String
            Get
                Return _name
            End Get
            Set(ByVal Value As String)
                _name = Value
            End Set
        End Property

        Public Property StyleSheet() As String
            Get
                Return _src
            End Get
            Set(ByVal Value As String)
                _src = Value
            End Set
        End Property

        Public Property UseSkinPath() As Boolean
            Get
                Return _useSkinPath
            End Get
            Set(ByVal Value As Boolean)
                _useSkinPath = Value
            End Set
        End Property
       
        Public Property Media() As String
            Get
                Return _media
            End Get
            Set(ByVal Value As String)
                _media = Value
            End Set
        End Property

#End Region

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            AddStyleSheet()

        End Sub

        Protected Sub AddStyleSheet()

            'Find the placeholder control
            Dim objCSS As Control = Page.FindControl("CSS")

            If Not objCSS Is Nothing Then
                'First see if we have already added the <LINK> control
                Dim objCtrl As Control = Page.Header.FindControl(id)

                If objCtrl Is Nothing Then
                    Dim skinpath As String = String.Empty
                    If UseSkinPath Then
                        skinpath = CType(Me.Parent, Skin).SkinPath
                    End If
                    Dim objLink As New HtmlLink()
                    objLink.ID = CreateValidID(Name)
                    objLink.Attributes("rel") = "stylesheet"
                    objLink.Attributes("type") = "text/css"


                    If String.IsNullOrEmpty(Media()) = False Then
                        objLink.Attributes("media") = Media()
                    End If

                    objLink.Href = skinpath + StyleSheet

                    If IsFirst Then
                        'Find the first HtmlLink
                        Dim iLink As Integer
                        For iLink = 0 To objCSS.Controls.Count - 1
                            If TypeOf objCSS.Controls(iLink) Is HtmlLink Then
                                Exit For
                            End If
                        Next
                        AddLink(objCSS, iLink, objLink)
                    Else
                        AddLink(objCSS, -1, objLink)
                    End If
                End If
            End If

        End Sub

        Protected Sub AddLink(ByVal cssRoot As Control, ByVal InsertAt As Integer, ByVal link As HtmlLink)
            If String.IsNullOrEmpty(Condition) Then
                If InsertAt = -1 Then
                    cssRoot.Controls.Add(link)
                Else
                    cssRoot.Controls.AddAt(InsertAt, link)
                End If
            Else
                Dim openif As New System.Web.UI.WebControls.Literal()
                openif.Text = String.format("<!--[if {0}]>", Condition)
                Dim closeif As New System.Web.UI.WebControls.Literal()
                closeif.Text = "<![endif]-->"
                If InsertAt = -1 Then
                    cssRoot.Controls.Add(openif)
                    cssRoot.Controls.Add(link)
                    cssRoot.Controls.Add(closeif)
                Else
                    'Since we want to add at a specific location, we do this in reverse order
                    'this allows us to use the same insertion point
                    cssRoot.Controls.AddAt(InsertAt, closeif)
                    cssRoot.Controls.AddAt(InsertAt, link)
                    cssRoot.Controls.AddAt(InsertAt, openif)
                End If

            End If
        End Sub
    End Class
End Namespace
 

 
New Post
1/8/2009 7:59 AM
 

to submit items for the issue tracker, please enter them to the PUBLIC issue tracker (2nd from top) at support.dotnetnuke.com, thank you. Please provide some information about the use case as well.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
1/10/2009 5:09 AM
 

did you manage to log this?

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsSkinsSkinsStyle.ascxStyle.ascx


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