3

Sitecore 根据 Sitecore 树中定义的项目名称生成 URL,

http://samplewebsite/Pages/Sample Page

但是我们的客户有兴趣降低所有 URL(页面/示例页面)的大小写,并使用连字符(示例页面)格式化空格。

我怎样才能做到这一点?

4

4 回答 4

9

在您的 web.config 中,您可以添加 节点<replace find=" " mode="on" replacewith="-"><encodeNameReplacements>使用连字符格式化空格。不过要小心 - 这意味着您不能再在项目名称中使用连字符(因为 Sitecore 会尝试查找其中包含空格的项目)

要小写您的 URL,您可以使用规则引擎,如 John West 在此处描述的:
使用 Sitecore 规则引擎控制项目名称

于 2013-04-08T10:05:41.900 回答
2

如果您在 App_Config/Include 中使用自定义配置文件,则可以在您的<sitecore></sitecore>标签之间使用以下配置补丁。这会将您的 URL 中的空格更改为破折号,并且不允许内容编辑器在其项目名称中使用破折号。

<encodeNameReplacements>
  <!-- Replace spaces in URLs with dashes -->
  <replace mode="on" find=" " replaceWith="-" />
</encodeNameReplacements>
<settings>
  <setting name="InvalidItemNameChars">
    <!-- Disallow dashes in item names for content editors because the above rule causes the page to crash -->
    <patch:attribute name="value">-\/:?&quot;&lt;&gt;|[]</patch:attribute>
  </setting>
</settings>
于 2014-02-06T23:24:07.010 回答
1

连字符替换的空格可以<encodeNameReplacements>Sitecore.config.

要对所有 url 使用小写字符,您需要扩展LinkManager类。它们都在这里解释:

http://csuwannarat.wordpress.com/2011/07/17/how-i-make-seo-friendly-sitecore-urls/

于 2013-04-08T10:05:15.820 回答
0

John West 在这里也发布了一个出色的解决方案:http ://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/11/Use-the-Sitecore-Rules-Engine- to-Control-Item-Names.aspx

于 2013-04-08T12:46:22.087 回答