语言回退不适用于具有标准值的字段(Sitecore 8.1) [英] Language Fallback not working for Fields with Standard Values (Sitecore 8.1)

查看:146
本文介绍了语言回退不适用于具有标准值的字段(Sitecore 8.1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们遇到一个问题,我们在基本模板的项目级别启用了后备语言设置,以使其适用于我们的所有项目.即使Sitecore内容编辑器指出它可以正常工作,它也可以处理大约90%的项目,但不适用于其他项目.

We had an issue where we enabled fallback language settings at the item level on a base template so that it would apply to all of our items. It worked for about 90% of our items but not for others even though the sitecore content editor indicated that it was working.

将此处放置在有此问题的其他任何人身上.我没有找到具体的 Google上针对此问题的解决方案,很幸运能够解决.希望这也可以帮助其他人.

Placing this here for anyone else who has this issue. I didnt find a specific solution for this issue on Google and was lucky enough to figure it out. Hopefully this can help someone else out too.

我们的设置是带有人居Asp.net MVC的Sitecore 8.1

Our setup is Sitecore 8.1 with Habitat Asp.net MVC

推荐答案

以下是通过将项目级别设置应用于基本模板来使语言回退适用于所有项目的一些步骤.

Here are some steps to make language fallback work for all items by applying item level settings to a base template.

第1步

启用语言回退的第一步是设置回退树. 我们可以为语言建立一种层次结构(或简单的线性) 示例:

First step to enable language fall-back is to set up the fall-back tree. We can build a hierarchical structure (or simple linear) for languages to fall back to Example:

在我们的情况下,我们只需要做以下操作:EN-NZ-> EN

In our case we would just do: EN-NZ --> EN

通过在每个语言节点上设置后备语言来完成/Sitecore/System/Languages的操作:

This is done /Sitecore/System/Languages by setting the fall-back language on each of the language nodes:

第2步

接下来,我们为网站启用语言回退功能. 在部署的网站上,找到配置文件 Sitecore.LanguageFallback.config 并修改配置,以便应用以下设置:

Next we enable the language fall back feature for the site. At the deployed website locate the config file Sitecore.LanguageFallback.config And modify the config so that the following settings apply:

<setting name="LanguageFieldFallback.AllowVaryFallbackSettingsPerLanguage" value="true" />
…
<sites>
      <site name="shell">
        <patch:attribute name="enableItemLanguageFallback">true</patch:attribute>
        <patch:attribute name="enableFieldLanguageFallback">true</patch:attribute>
      </site>
      <site name="website">
        <patch:attribute name="enableItemLanguageFallback">true</patch:attribute>
        <patch:attribute name="enableFieldLanguageFallback">true</patch:attribute>
        <patch:attribute name="enforceVersionPresence">true</patch:attribute>
      </site>
    </sites>

回收应用程序池

第3步

现在为网站启用了功能,我们必须在项目级别启用该功能.

Now the feature is enabled for the site we must enable the feature at the item level.

  1. 在sitecore内容编辑器中导航至某个项目,然后查看高级"部分
  2. 如果高级"部分不可见;选择查看"标签,然后选中标准字段"选项
  3. 选中启用项目后备"选项. (如果不存在任何语言版本,则显示来自备用语言的项目)
  4. 要将页面限制为某种语言,请选中强制版本存在"选项. 如果找不到特定语言的版本,Sitecore的默认行为是返回一个空项目.呈现项目或尝试通过Sitecore API访问项目时,会发生这种情况. 如果没有适用于所请求语言的版本,则可以使用此选项告诉Sitecore不要退回任何商品.这样最终会将用户重定向到404(未找到)页面,或者在尝试通过API获取商品时返回NULL.
  1. Navigate to an item in the sitecore content editor and view the Advanced section
  2. If the Advanced section is not visible; select the View tab and check the Standard fields option
  3. Check the Enable Item Fallback option. (Displays item from fallback language if no language version exists )
  4. To restrict a page to a certain language, check the Enforce Version Presence option. In cases where a version is not found for a specific language, Sitecore's default behavior is to return an empty item. This happens when rendering an item or when trying to access it via Sitecore API. In cases where there’s no version available for the requested language, this option allows you to tell Sitecore NOT to return an item. This will end up redirecting the user to a 404 (not found) page, or returning NULL when trying to get the item via API.

我们可以在标准模板上应用这些设置,并且该设置将应用于所有继承它的项目

We can apply these settings on the Standard Template and the setting will apply to all Items that inherit it

  1. 导航到标准模板
  2. 创建标准值(如果不存在)
  3. 设置启用项目后备选项"

这将使我们90%的项目和领域都可以使用,但是需要注意的是;这仅适用于不从标准值继承其值的字段.

This will get 90% of our items and fields working, however there is a caveat; this only works for fields that do not inherit their values from Standard Values.

您可以通过在内容编辑器中查看项目来轻松识别这些字段

You can easily identify these fields by viewing the Item in the content editor

这与如何从标准模板的标准值中继承启用项目后备选项有关,并且Sitecore不会将该设置应用于也从标准值继承的字段中.

This is something to do with how the Enable Item Fallback option is also inherited from Standard values of Standard Template and Sitecore won’t apply the setting to the fields that also inherit from standard values.

要在这种情况下处理字段/项目,请执行以下两项操作之一:

To handle fields/items in this scenario you do one of two things:

  1. 修改项目上的字段,使其不继承标准值 或:
  2. 在项目"模板上创建标准值–它将从标准"模板的标准值"继承启用项目回退"选项
  1. Modify the field on the Item so that it does not inherit from standard values OR:
  2. Create a standard values on the Item template – It will inherit the Enable Item Fallback option from the Standard Values of the Standard Template
  1. 取消选中该选项并保存
  2. 重新选中该选项并保存,以使其不再继承设置
  3. 现在,继承项启用"选项不会被继承,它将应用.从标准值继承的项目中的字段现在将回退并呈现

注意: 我相信这是一个错误,因为当您更改语言时,内容编辑器仍将字段显示为从后备语言继承其内容,但是只有执行上述方法之一,该内容才会在网站上呈现

Note: I believe this is a bug because the content editor still displays the fields as inheriting their content from the fall back language when you change language however the content doesn’t render on the website until you do one of the methods mentioned above

评论

  • 也有字段级别设置可以应用相同的设置.
  • 还值得注意的是,如果您遇到上述问题并在现场一级应用设置,那么在您执行上述步骤之前,该设置仍然无法使用.

这篇关于语言回退不适用于具有标准值的字段(Sitecore 8.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆