Just a quick note with another way to deal with this:
The "cy" in the URL probably comes from a node, right? E.g. I usually do this:
Content
website.com (Website node)
Products (Textpage node)
website.dk (Website node)
Produkter (Textpage node)
...
And then I have an umbracoUrlName property on the Website nodes where I put the language code, which then automatically gives me the /da or en/ part of the URLs.
So in XSLT I can add a stylesheet like the one in your example, just by taking the umbracoUrlName property of the Website ancestor, however deep the current page may be, e.g.:
The advantage to this is of course that you're not inspecting the URL, and you don't have to add a new code fork for every new language you add (and you won't accidentally get the cy.css file on pages called /cycling/cyanide-stain-removal etc. :-)
The cultures come from hostnames set against 2 homepage nodes, en and cy set to en-GB and cy-GB (see attached) So when the language selector is used it sets www.mysite.com/en or /cy
Testing the code you wrote above writes this to the page regardless of which language is selected:
Yes - we're using the same setup, I can see - I'm just using an umbracoUrlName property so I don't have to put "en" and "cy" as the names of my "Website" nodes.
To make it work in your setup, you should take the @nodeName instead (and I've made it use @level instead of the DocumenTypeAlias so it's more portable):
If current URL contains
Hi all,
just a quick one if anyone can help please...
I am trying to check whether the current URL contains a culture name and if so, write a style sheet to screen.
The cultures in the URLs are either en or cy so a typical URL would be:
www.thissite.com/en/thispage.aspx or www.thissite.com/cy/thispage.aspx
My XSLT is:
<xsl:variable name="url" select="umbraco.library:RequestServerVariables('URL')" />
<xsl:variable name="culture" select="cy" />
<xsl:if test="contains($url, $culture)">
<link href="/css/cy.css" rel="stylesheet" type="text/css" />
</xsl:if>
The stylesheet is writing to screen on both URL's
Can anyone shed some light on this please?
Thanks!
I've just sorted the solution:
<xsl:variable name="currentURL" select="umbraco.library:RequestServerVariables('URL')" />
<xsl:variable name="cultureRequest" select="contains($currentURL, '/cy')" />
<xsl:if test="$cultureRequest">
<link href="/css/cy.css" rel="stylesheet" type="text/css" />
</xsl:if>
Hi Roger,
Just a quick note with another way to deal with this:
The "cy" in the URL probably comes from a node, right? E.g. I usually do this:
And then I have an
umbracoUrlName
property on the Website nodes where I put the language code, which then automatically gives me the /da or en/ part of the URLs.So in XSLT I can add a stylesheet like the one in your example, just by taking the
umbracoUrlName
property of the Website ancestor, however deep the current page may be, e.g.:The advantage to this is of course that you're not inspecting the URL, and you don't have to add a new code fork for every new language you add (and you won't accidentally get the cy.css file on pages called /cycling /cyanide-stain-removal etc. :-)
/Chriztian
Hi Chriztian,
The cultures come from hostnames set against 2 homepage nodes, en and cy set to en-GB and cy-GB (see attached)
So when the language selector is used it sets www.mysite.com/en or /cy
Testing the code you wrote above writes this to the page regardless of which language is selected:
<link href="/css/.css" rel="stylesheet" type="text/css" />
Thanks
Roger
Hi Roger,
Yes - we're using the same setup, I can see - I'm just using an
umbracoUrlName
property so I don't have to put "en" and "cy" as the names of my "Website" nodes.To make it work in your setup, you should take the
@nodeName
instead (and I've made it use@level
instead of the DocumenTypeAlias so it's more portable):/Chriztian
is working on a reply...