Products

Solutions

Resources

Partners

Community

About

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...Language and In...Language and In...Using JS to add regional stylessheet to appropriate region's page. Using JS to add regional stylessheet to appropriate region's page.
Previous
 
Next
New Post
3/3/2018 1:35 AM
 
Our site has a couple regions / languages. I would like to add a stylesheet to a page, if it is a certain language. I noticed in the HTML element is lang="en-US".

So I figured I'd use that to add my regional css file. I want it to come after all of my other stylesheets. Right now I have all of my stylesheets right after all of the "Register TagPrefix="dnn" TagName... ect" things in my ASCX file.

So the top of my ascx/layout file looks like this:

....Prefix="dnn" TagName="STYLES" Src="~/Admin/Skins/Styles.ascx" %>
><%@ Register TagPrefix="dnn" TagName="LINKS" Src="~/Admin/Skins/Links.ascx" %>
<%@ Register TagPrefix="dnn" TagName="MENU" src="~/DesktopModules/DDRMenu/Menu.ascx" %>
<%@ Register TagPrefix="dnn" TagName="LANGUAGE" src="~/Admin/Skins/Language.ascx" %>

<link href="<%= SkinPath %>css/bootstrap.min.css" rel="stylesheet">
<link href="<%= SkinPath %>css/style.css" rel="stylesheet">
<link href="<%= SkinPath %>css/lang/gfsiStyle.css" rel="stylesheet">
<REGIONAL STYLESHEET SHOULD BE ADDED HERE BY JS>


Then I added this script to the ascx file above the div class=container-fluid:

<script>        
 $(document).ready(function) ()
           {
               if($("html").hasAttr(lang='en-US'))
               {
               $("link[href='/Portals/_default/skins/gfsi/css/lang/gfsiStyle.css']".after("<link href='/Portals/_default/skins/aib/css/lang/CSSDocToBeAdded.css' rel='stylesheet' type='text/css'/>")
               }
            }
</script>

I'm just using 'en-US' right now as an example. Once I get this to work, I'll replicate this js for each of my regions.

It's not working though. I am new to Javascript so it probably is something obvious.
 
New Post
3/3/2018 10:12 PM
 
FIGURED IT OUT.
finally.

$(document).ready(function ()
{ var language= $('html').attr('lang');
if(language == 'en-US')
$(".stylesheets").after("<link href='/Portals/_default/skins/aib/css/lang/EXAMPLE.css' rel='stylesheet' type='text/css'/> ");
});
 
New Post
3/3/2018 10:15 PM
 
Oh. And I added a class to the stylesheet I wanted the regional stylesheet to be added after. So now the top part of my ascx file looks like:







........="dnn" TagName="PRIVACY" Src="~/Admin/Skins/Privacy.ascx" %>
<%@ Register TagPrefix="dnn" TagName="STYLES" Src="~/Admin/Skins/Styles.ascx" %>
<%@ Register TagPrefix="dnn" TagName="LINKS" Src="~/Admin/Skins/Links.ascx" %>
<%@ Register TagPrefix="dnn" TagName="MENU" src="~/DesktopModules/DDRMenu/Menu.ascx" %>
<%@ Register TagPrefix="dnn" TagName="LANGUAGE" src="~/Admin/Skins/Language.ascx" %>


  <link href="<%= SkinPath %>css/bootstrap.min.css" rel="stylesheet">
  <link href="<%= SkinPath %>css/style.css" rel="stylesheet">
  <link href="<%= SkinPath %>css/lang/gfsiStyle.css" class="stylesheets" rel="stylesheet">

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Language and In...Language and In...Using JS to add regional stylessheet to appropriate region's page. Using JS to add regional stylessheet to appropriate region's page.


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