网址中的 Sitecore 国家/地区 ISO

发布于 2024-12-09 05:09:15 字数 687 浏览 0 评论 0原文

我在 sitecore 中创建了一个具有多种语言的网站...我在内容编辑器(系统>语言)中指定了三种语言(荷兰语、英语和德语)。不,我有两个问题。

例如,当某个项目有英语版本但没有德语和荷兰语版本时,我输入德语站点的地址:www.testsite.com/de 我会得到德语站点,但没有内容。在本例中,我希望显示 404 页面。

另一个问题是当我转到系统>中未指定的语言时语言和项目上仍然有一个空网站。在这种情况下,我还希望显示 404 页面。只要页面是有效的 ISO 代码,Sitecore 就会显示该页面。

我正在使用 Sitecore 6.4

有人能解决这些问题吗?

提前致谢!

mrtentje

My LinkManager 在 Web.config 中指定如下:

<add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" addAspxExtension="true" alwaysIncludeServerUrl="false" encodeNames="true" languageEmbedding="asNeeded" languageLocation="filePath" shortenUrls="true" useDisplayName="false"/>

I have created a site with multiple languages in sitecore... I the content editor (system > languages) I have specified three languages (Dutch, English and German). No I have 2 problems.

When an item has, for example: an English version but no German and Dutch version and I type the address to the German site: www.testsite.com/de I get the German site, but without content. In this case I want a 404 page to be shown.

Another problem is when I go to language that is not specified in system > language and also on the item is still get an empty site. In this case I also want a 404 page to be shown. Sitecore shows the page as long as it is a valid ISO-code.

I'm using Sitecore 6.4

Does anybody has a solution for these problem(s)?

Thanks in advance!

mrtentje

My LinkManager is specified as follows in the Web.config:

<add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" addAspxExtension="true" alwaysIncludeServerUrl="false" encodeNames="true" languageEmbedding="asNeeded" languageLocation="filePath" shortenUrls="true" useDisplayName="false"/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滴情不沾 2024-12-16 05:09:15

不幸的是,您必须在 Sitecore 中手动管理这两种情况,它们都有非常简单的解决方案,但需要您进行一些开发。

对于第一个(访问没有翻译的页面),我认为您需要扩展 Sitecore 中当前的 ItemResolver 并让它显式检查是否存在所选语言的版本。我自己还没有实现这一点,但这就是我处理它的方式。

第二个(仅接受某些语言)是我处理过的事情,Sitecore 本身无法处理它确实让我很困扰(尽管也许它可以处理但我错过了)。为此,我在 LanguageResolver 之后立即在管道中创建了一个名为 PermissableLanguageChecker 的步骤。这会检查请求的当前语言是否是某些允许值之一,如果不是,则将语言设置回默认语言,或者在您的情况下抛出 404。

对于“允许值”,我使用新属性从站点配置中读取它们:

<site name="website" ... permissableLanguages="pl-PL,en" language="pl-PL" ... />

permissableLanguages 属性很方便,因为我们稍后在向用户呈现语言选择控件时也可以在站点中使用它。

Unfortunately you have to manage both of these scenarios manually in Sitecore, they both have quite simple solutions but will require some development on your part.

For the first (accessing of pages without translations) I think you would need to extend the current ItemResolver within Sitecore and have it explicitly check that a version exists for the language that has been selected. I haven't implemented that myself but that's how I'd look at handling it.

The second (only accepting certain languages) is something I have handled, and it really bothered me that Sitecore couldn't handle it itself (though perhaps it does and I missed it). For this I created a step in the pipeline immediately after the LanguageResolver called PermissableLanguageChecker. This checks to see if the current language of the request is one of certain allowable values, and if it isn't it sets the language back to the default language, or in your case throw a 404.

For the "allowable values", I read them from the site config with a new property there:

<site name="website" ... permissableLanguages="pl-PL,en" language="pl-PL" ... />

That permissableLanguages property is handy as we can also use it later on in the site when presenting a language selection control to the user.

好久不见√ 2024-12-16 05:09:15

您可能需要查看 Sitecore 共享源库中的Language Fallback 模块。因为它涵盖了您的一些场景。

http://trac.sitecore.net/LanguageFallback

You may want to take a look at the Language Fallback module in the Sitecore Shared Source Library. As it covers some of your scenarios.

http://trac.sitecore.net/LanguageFallback

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文