The filters are for both Js, CSS and Meta tags.
If you need different filter for JS and CSS for instance, you have to add the skin object to the page twice.
You can however switch filtering on/off for removal/adding.
Used to switch filtering for CSS file removal on or off (defaults to true).
Used to switch filtering for CSS / JS / Meta tag file removal on or off (defaults to true).
Effect or filters
Only filters that have a value set are used.
Most filters accept a comma (,) separated list.
If one of them fits, the filter passes.
The result is an OR combination of the different values.
If you use IfUserName="Timo,Peter" the filter is passed if the Username of the current User = Timo OR Peter.
You can exclude values too, you do this by starting the value with an exclamation sign (!).
IfUserName="!Timo" will pass for all authenticated users but Timo.
IfUserName="!Timo,!Peter" passes for all users but Timo and Peter
Most filter use a regular expression meaning that "Tim" will match both "Tim" and "Timo".
If you want to match only "Tim" you should add a $ at the end; "Tim$".
$ references the end of a string in regular expressions.
The Filters are not case sensitive.
Debug you filters
If the filters don't behave the way you expect them, you can force the skin object to write some of the detected values to the page.
This includes the Browser version, current user name, Roles, etc.
All filters listed at the bottom of this page
Supported Filters / Conditions
Browser (+ version)
Will filter on the visitors browser and version.
You can also exclude browsers.
Pass a list of comma separated browsernames. Browsers = "ie,firefox" would only add the files if the visitor uses ie or firefox.
You can also filter on browser version, for that you need to add the version and an equals sign.
The version can be passed as as a number with major and sub version number.
You set how the version is interpreted by adding a an equasion sign.
Use = for this specific browser version.
Use > n, for browser version higher then n
Use < n, for browser version lower then n
You can exclude a certain browser by starting with an exclamation sign.
Browser = "Firefox" Will render for all Firefox browsers
Browser = "!Firefox" Will render for all browsers that are not Firefox
Browser = "IE=6" Will render only for Internet Explorer 6
Browser = "IE<8" Will render for IE browsers below version 8
Browser = "!IE<7" Will render for any browser but IE below 7
Notes on browser detection:
The browser is tested against how ASP.NET detects the browser.
This is done using browser files in the App_Brosers folder of DNN.
This is not always 100% correct, especially for not so common browsers
You can always (find an) update for the browser files, to make ASP.NET detect the browser correctly
Alternatively you could use the UserAgent attribute to interpret the raw user agent string.
Check the DNN version (From SH version 02.10.00)
Use: With this filter you can filter on the DNN version
You can use the floowing values:
"8" for DNN 8
"7.2.0" for DNN DNN 7.2.0 only
">8" for all above DNN 8
">=8" for DNN 8 and above
"<=8" for DNN 8 and below
"<8" for all below DNN 8
<fortyfingers:STYLEHELPER ID="FFSH1" IfDnnVersion="=>6.1" Content="DNN 6 and above" runat="server" />
Will insert the content if the DNN is version 6.1 or higher.
Check for mobile browsers
Use: With this filter you can filter on "Mobile visitors".
It uses this technique to check if the users browser is a mobile browser based on the a regular expresion
If you don't set the attribute, there is no filtering.
You set the attribute to True if you want to filter on Mobile browsers.
You set the attribute to False if you want to filter on NON-Mobile browsers.
<fortyfingers:STYLEHELPER ID="FFSH1" IfMobile="True" AddCssFile="[S]//Mobile.css" runat="server" />
Will load Mobile.css if the users uses a Mobile browser
IfMobile uses 2 regular expressions (match 1 OR 2) to detect mobile browsers. You can reset these two Regular Expression through the DetectMobileRegex1 and DetectMobileRegex2 attributes. (set the second to "" if you need only one).
Filter on Cookie values
Use: With this attribute you can use conditions based on Cookies you either set yourself or that are set by DNN.
Use: With this attribute you can use conditions based on the fact that a cookie does not exist.
UserAgent String Conditions
Compares your values with the detected user agent string (using regular expressions)
An example user agent string for Firefox looks lik this:
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:22.214.171.124) Gecko/20100401 Firefox/3.6.3"
IfUserAgentString="firefox" would match all firefox browsers (ASP.NET independent)
Checks if the current user name is one of the values you pass.
IfUserName="Timo,Peter", will pass if the username containIfUserName="!Timo,!Peter", will pass if the username does not contain Timo nor Peter.
Checks if the current user is in any of the roles you pass.
You can pass multiple roles (comma separated).
Please note that the test function exits as soon as one of the passed values is found so this works as an OR for multiple values.
So IfRole="editor,manager' will be true if a user is a member of one or both roles.
IfRole="editor,!manager' will not work as "Editor but not Manager" the second value will not be tested.
IfRole="None", will match all users not in any roles (unauthenticated users)
IfRole="Administrators" will match all users in the Administrators role.
IfRole="!Administrators" will match all users not in the Administrators role.
IfRole="SuperUsers" will match all Host / Superusers
IfRole="!Administrators,!SuperUsers" will match all users that are not an Administrator nor a Superusers
State of the Control Panel
Use: Filters on the state of the ControlPanel
Tests if the value you pass is part of the current pages URL.
You can also use this to test for certain pages, portal alias etc.
IfURL="Contact" matches all pages with contact in the URL.
IfURL="!Contact" matches all pages without contact in the URL.
IfURL=" www.mydomain.com" will match a certain domainname (or portal alias)
Tests if the current ASP.NET culture, matches one of the passed values.
The format used is the ASP.NET culture format: en-US, fr-FR, NL-nl etc)
IfCulture="fr-FR" will match if the culture is fr-FR.
IfCulture="fr-" will match all cultures using French.
IfCulture="!fr-" will match all cultures, but the ones using french.
Conditional Content using Style Helper based on Tokens. "IfToken" will be true if the passed Token String returns anything but an empty String
<fortyfingers:STYLEHELPER ID="SH0" IfToken="[Page:Title]" Content="Page Title: [Page:Title]" ContentFalse="No Page Title" runat="server" />
<fortyfingers:STYLEHELPER ID="SH1" IfToken="[Page:IconFile]" Content="Page Icon: [Page:Icon]" ContentFalse="No Page Icon" runat="server" />
<fortyfingers:STYLEHELPER ID="SH2" IfToken="[Page:IconFileLarge]" Content="Page Large Icon: [Page:IconLarge]" ContentFalse="No Page Large Icon" runat="server" />
Conditions for StyleHelper based a value passed from the skin, this allow you to add custom condition code to your Skins ASCX to influence the behavior of the StyleHelper
<script runat="server"> Function Random() As String Dim RandGen As New Random Return RandGen.Next(0, 2).ToString End Function </script>
<fortyfingers:STYLEHELPER ID="SH0" IfExternal="<%#True%>" Content="External Value = True" runat="server" />
<fortyfingers:STYLEHELPER ID="SH1" IfExternal="<%#Random()%>" Content="Randomly True" runat="server" ContentFalse="Randomly False" />
Tests the current text direction.
You can use either "rtl" or ltr"
IfTextDir="rtl" will pass for RTL languages
Filter with the querystring parameter.
This means you could switch a CSS file off or on using a query string parameter.
You pass the parameter name and value separated by a semicolon.
IfQS="color:red" could load a css file using this URL:
You can use IfQS="!color" to detect the lack of a parameter
You can use IfQS="!color:black" to detect the lack of a parameter value
Please note that this is not persistent, the next page without the querystring parameter, the file will not be loaded.
In a future version I'll add support for cookies, so the file will be persistent.