Sitecore multisite setup with language-culture in url - sitecore

I want to setup a sitecore solution containing multiple sites. The sites hostnames need to have the suffix language-culture, so I want the urls to be like:
[HOST]/de-DE
[HOST]/sv-SE
[HOST]/fr-BE
[HOST]/nl-BE
I tried to configure the sites with virtualpaths like "de-DE", but that does not help. How should this be configured?
And if I want the belgium site (fr-BE and nl-BE) to be one site with multiple languages (translations), but reachable from given url structure, how should that be setup?

You may have better luck getting answers on https://sitecore.stackexchange.com/, however, I will answer here as I am unable to move your question.
It sounds to me like you need a mixture of both separate website nodes for each site, as well as translated versions within some of those sites (fr-BE and nl-BE).
As long as the site definitions are patched in before the website node, they should be picked up by Sitecore's site resolver based on the virtualFolder. Please note there is a special requirement when using virtualFolders in which the physicalFolder value must match. More info on that here.
<site name="fr-BE" ... virtualFolder="/fr-BE" physicalFolder="/fr-BE" rootPath="/sitecore/content" startItem="/Home Belgium" language="fr-BE" ... />
<site name="nl-BE" ... virtualFolder="/nl-BE" physicalFolder="/nl-BE" rootPath="/sitecore/content" startItem="/Home Belgium" language="nl-BE" ... />
<site name="de-DE" ... virtualFolder="/de-DE" physicalFolder="/de-DE" rootPath="/sitecore/content" startItem="/Home Germany" language="de-DE" ... />
<site name="website" ... virtualFolder="/" rootPath="/sitecore/content" startItem="/Home" ... />
Notice how the first two site definitions point to the same start item (/Home Belgium in my example). This allows you to still use Sitecore's language version translation on that site, while keeping the item tree structure separate from the German site.
Next, you will need to turn off the strip language processor that is responsible for identifying and removing the language prefix from each request. This is on by default and will prevent you from using virtual folders that match a language code.
<!-- Set to false to allow language code virtual folders -->
<setting name="Languages.AlwaysStripLanguage" value="false" />
Lastly, make sure you have the proper languages installed and that your content is published in the appropriate languages.

Related

How can I prevent Sitecore content from being accessed under any language identifer?

How do you remove the ability to find content under language identifiers in Sitecore?
Content here:
/about
Is also available at:
/en/about
Weirder yet, any attempt to find content under a different language identifier results in an error about not being able to find Views.
/es/about
/pt-br/about
/aa/about (this is invented..)
I don't want content available under any language identifier -- the URLs above should simply be 404s.
I can't find where this language identifier is isolated and processed. I removed the LanguageResolver from the httpRequestBegin pipeline, but this didn't change the behavior.
There are many blog posts about turning off language embedding in the LinkManager, which I've done, but that's not enough -- I do not want content being produced under any language code. The firs segment of the URL should be treated like any other segment. Requests for /en/[whatever] should 404.
As well as setting the LinkManager to never embed, you also need to set the Languages.AlwaysStripLanguage setting to false.
Source: http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2015/03/prevent-the-sitecore-aspnet-cms-from-interpreting-url-path-prefixes-as-language-names.aspx
Assuming you already have a custom 404 resolver in place, you just need to change the Sitecore setting Languages.AlwaysStripLanguage from true to false like so:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="Languages.AlwaysStripLanguage" value="false" />
</settings>
</sitecore>
</configuration>

How do I prevent sitecore from adding a ~ to an image path?

I have a clean install of Sitecore 6.5, DMS 2.0, and the E-Commerce Module and Sample Site (v1.2). When I have the sample site installed, most of the images appear to be broken. The HTML that is rendered includes img src attributes that contain a path that start with /~/. Example:
http://~/media/Images/Ecommerce/Examples/Products/Digital%20SLR/D200.ashx?w=250&as=1
Now, I'm assuming this is either because the sample site hasn't been updated in a while to stay current with Sitecore changes, or there is a configuration for media paths that get returned from it. Here's an example of the XSLT rendering used to write the image:
<img id="product_shot" class="fix" alt="{sc:fld('alt',.)}" title="{sc:fld('alt',.)}" src="/{sc:GetMediaUrl(.)}?w={$ImageWidth}&as=1" />
Does anyone know of a way to prevent the image url from being rendered with a ~ when using XSLT? Did I do something wrong with my initial setup and configuration?
John West gives a great breakdown here: http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2012/12/Sitecore-Idiosyncrasies-Media-URLs.aspx
The important info being a configuration of "Media.MediaLinkPrefix". You can create a patch file, or modify your Web.config to change it to something else. The places I've read have people changing it to a single dash "-/media"
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="Media.RequestExtension">
<patch:attribute name="value"></patch:attribute>
</setting>
<setting name="Media.MediaLinkPrefix">
<patch:attribute name="value">-/media</patch:attribute>
</setting>
</settings>
<customHandlers>
<handler trigger="-/media/" handler="sitecore_media.ashx"/>
</customHandlers>
</sitecore>
</configuration>
Another solution which I can think of is to change your web.config like this:
InvalidItemNameChars: Add “~“
But this will work not only for images but for any content items out there in your Sitecore content tree.
This is more of a workaround than a solution. Since I'm setting this up for demo purposes, it'll do just fine.
In web.config, I changed the value of Media.MediaLinkPrefix to include the hostname and media prefix. Since the Sitecore E-Commerce Example Site XSLT renderings start all calls to sc:GetMediaUrl(.) with a / character and sc:GetMediaUrl(.) itself returns its first character as a /, this causes the src attribute value to be written with the full host name and then correctly resolves:
<img src="//sitecore.local/~/media/Images/Ecommerce/Examples/Products/Digital%20SLR/D200.jpg />
Far from ideal, but for these purposes, this workaround did the trick.

HTML5 PushState Regex Issue

I've been experimenting with Backbone for a project I'm working on, and I've been having problems with getting Backbone's 'pushState' functioning how I'd like to.
I've got a simple project consisting of 4 views, and a router. I'm routing via the id of the elements if it matters in this case. When I go to the hash for one of the views (http://example.com/backbonetest/#step1), it's displayed correctly, and the url is changed. This is what I'd expect to happen here, but the problem comes when I try and navigate to the same thing without the hash in it (http://example.com/backbonetest/step1). I get a 404 on the server (IIS) which is to be expected, as the page doesn't exist.
What I've been trying to do all day is write a regex expression for IIS which would catch and rewrite the url, removing the fragment at the end of the url so the page is served correctly. I'd rather simply rewrite the url than having a physical file with the same name, as the content of the page will be dynamically generated, and will require scripts to get the content anyway.
The issue I've come across may be related to how I need to have the folders/scripts/styles structured on the file system. I was hoping to be able to have the whole example contained within the /backbonetest/ folder. For scripts, 'backbonetest/scripts' and so on.
I made a list of URLs which I've been testing my regex expressions against, and the results I've been trying to achieve:
Input: Output:
2
a2
ab2
ab22
step2
script.js script.js
scripts/ scripts/
555/stuff 555/stuff
scripts/script.js scripts/script.js
Edit: I've since found that the url which is used does not include the preceding slash,
which is why Qtax's solution doesn't work in IIS. The new input structure is shown above.
The '/555/stuff' url I would expect to 404 as normal. I only want to rewrite the url if there are no subdirectories defined other than the current one, and if the url doesn't reference an explicit file (one with an extension for example).
I've been scouring the net all day for a solution to this, as well as experimenting with regexr, but not managed to come up with the proper solution to my problem. After not finding a single thing anywhere, I'm thinking I must be looking at this the wrong way...
Can anyone help me out please?
After much head/desk banging, I've come up with the solution. It's irritatingly simple for all the fuss it's caused:
^[^\./]+$
Essentially:
Replace if the url doesn't contain a '/' or a '.' anywhere in it.
This should now be a solution for anyone using IIS with Backbone and HTML5 push state. Just pop it in the web.config in the root of your app, and change the rewrite action to ".", and it should just work.
This melted my brain all morning!
I've added to this - In my scenario, I have an API project which sits in an API virtual directory (to eliminate the need for CORS) - I obviously don't want to rewrite any of the PAI calls, so I re-wrote mine as follows - you can do similar for your API URLs if needed...
<rule name="Handle PushState">
<match url="^[^\./]+[^\./api]+(.*)$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="." />
</rule>

Why might a sitecore presentation component produce different output dependent on domain?

As I can't post code I'm asking this as a theoretical question, but giving a scenario.
I have a "newsroom" sublayout, which staticaly binds a couple of XSLTs to list latest news and latest events. The sublayout is used on a newsroom item, the events and news items are descendants of it (though not direct child items, there are a couple of layers of folders to categorise and date items).
The subayout is in use in around 10 sites in our solution with no problem. Each site is a clone of our main site with an extra language version added. We hae succesfully used this with (amongst others) Japanese, Chinese, Russian, Polish and Czech language sites.
Our most recent clone (Turkish), however, shows no items in the event or news lists. The items exist and are published, and display as expected when browsed individually.
The presentation details for the newsroom item are identical to all other newsroom items.
Even more perplexing, the newsoom item itself, when displayed in the context of a different domain, displays correctly.
i.e.
www.mysite.com/sitecore/content/my_turkish_site/path/newsroom?sc_lang=tr-TR
shows the lists without a problem, including dates formatted according to culture, but
www.mysite.com.tr/sitecore/content/my_turkish_site/path/newsroom?sc_lang=tr-TR
shows empty lists.
The exact same problem occurs if language is switched to English (the language of the source of the clone)
Almost all of the Turkish site is working properly.
None of the presentation components are marked as cachable.
None of the presentation components have a specified data source (i.e. they all use the current item/descendants axis)
What are the possible causes of this problem, and how can I test them?
EDIT:
For Mark Ursino
This is the site definition (slightly fictionalised). I can't post that much more of the web.config...
<site name="www.mysite.com.tr" patch:after="site[#name='www.mysite.com.au']" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/CloneData/TurkishClone" hostName="www.mysite.com.tr" startItem="/Turkey_Home" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" language="tr-TR" />
Some debugging shows that the XSLTs aren't matching the template when the item is viewed in the Turkish context.
This is the debug match used (the select is what we use in our for-each):
<xsl:value-of select="count(./descendant::item[#template='newsitem' and #id!=$topNewsId and sc:fld('__created',.)])"/>
It matches on the same item viewed from other domains.
Debug output shows the Turkish site thinks the template is newsıtem instead of newsitem (the i is wrong!).
I've also tested viewing the newsroom of other sites through the Turkish domain - the problem is the same.
We have the same problem with items based on the eventitem template, and apparently with an Image Spot template.
Have you tried printing out the language, culture and context item id, lang, version within your events lister and xslts?
If that shows anything unexpected you could step-in to some of the Sitecore pipeline resolvers with Reflector Pro's external assembly debugging.
Answering my own question.
Sitecore template names are converted to lower case for use in XSLT comparison, by the Sitecore XSLT extensions.
This lower case conversion hasn't been set as culturally invariant. In Turkish, forcing lower casing of a upper case I gives the lower case ı
Sitecore has replaced calls with ToLower() in the Sitecore API with ToLowerInvariant() as of 6.5 rev.110419
http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%206/ReleaseNotes/ChangeLog.aspx
As we're not upgrading to 6.5 quite yet we'll be using template IDs rather than names in XSLT for now.
.Net info on strings and culture, including specifically the "Turkish I problem"
http://msdn.microsoft.com/en-us/library/ms973919.aspx

Sitecore set/change default language from 'en'

Can anyone recommend the best way to change the default language in Sitecore 6.1. On a fresh install, the typical language for all items is 'en' English, witha nice little USA flag and all.
However, we are setting up a system which is targeting en-AU and en-NZ. When I rename the main 'en' language item in any database, every other item is left without a version in the "correct" language. I recall in the past that renaming this item causes an update across the whole system, but that didn't seem to be the case when I tried it today.
Is there an easy "Sitecore" way to convert all default items to the primary language en-AU? I've considered running a sql update script over the database, but am hoping there is a neater way of doing it.
I don't think that changing anything about the en-language is a good idea. A lot of internal Sitecore objects are based on that language and you could risk loosing labels and help texts in the Sitecore UI.
We usually create all templates, renderings and layouts in the en-language and then create the content items for each language.
Instead you should set the language property in web.config for your site.
Here is an example that we are using from one of our multi-language solutions:
<site name="website_no" hostName="www.site.no|site.no" language="no" />
<site name="website_en" hostName="www.site.com|site.com" language="en" />
<site name="website" language="sv" />
The last line catches all requests not caught by the two first ones.
Couldn't get a site to use Danish as default language for backend UI based on value language="da" in <site...> tag. Changed it to da-DK, which made it work. Don't know if this is expected behaviour, but one might use the fully qualified ISO code to make sure, things are good.