Kentico 子文档能否继承其自定义URL路径';她在肯蒂科的父母
我有一种情况,我的客户希望他们的文档有SEO友好的URL,并且这些URL向下流到客户文档。以下是一个示例设置: 根Kentico 子文档能否继承其自定义URL路径';她在肯蒂科的父母,kentico,Kentico,我有一种情况,我的客户希望他们的文档有SEO友好的URL,并且这些URL向下流到客户文档。以下是一个示例设置: 根 团体 Group1(自定义url=/groups/ma/salem/Group1) 第1页 第2页 Group2(自定义url=/groups/ma/boston/Group2) 第2页 第4页 等等 希望Page1、Page2、Page3、Page4继承其父级的自定义url,并为: /组/ma/salem/group1/page1 /组/ma/salem/gro
- 团体
- Group1(自定义url=/groups/ma/salem/Group1)
- 第1页
- 第2页
- Group2(自定义url=/groups/ma/boston/Group2)
- 第2页
- 第4页
- 等等
- Group1(自定义url=/groups/ma/salem/Group1)
- /组/ma/salem/group1/page1
- /组/ma/salem/group1/page2
- /组/硕士/波士顿/组2/page2
- /组/硕士/波士顿/组2/page3
- /组/组1/page1
- /组/组1/page2
- /组/组2/page2
- /组/组2/第3页
我使用的是Kentico 8.1,在树中创建这些文档肯定是最简单、最安全的解决方案,但是如果您想避免这种情况,我看到了另外两种选择 1) 创建URL重写规则以模拟此树层次结构 2) 捕获事件之前的文档插入,并根据需要设置自定义URL路径 代码可以如下所示:
DocumentEvents.Insert.Before += DocumentInsert_Before;
private static void DocumentInsert_Before(object sender, DocumentEventArgs e)
{
TreeNode node = e.Node;
if (node.NodeAliasPath.StartsWith("/groups/group1")) {
string safeNodeName = TreePathUtils.GetSafeDocumentName(node.DocumentName, CMSContext.CurrentSiteName);
string customPath = "/groups/ma/salem/group1/" + safeNodeName;
// Handle multiple dashes
customPath = TreePathUtils.GetSafeUrlPath(path, CMSContext.CurrentSiteName, true);
node.DocumentUrlPath = customPath;
}
}