如何使用 Geta Sitemap 排除包含文件夹中的特定子文件夹?
How do I exclude specific subfolders within an included folder using Geta Sitemap?
如何从包含文件夹内的站点地图中排除与特定模式匹配的子文件夹?
例如,我希望排除符合以下条件的所有子文件夹:/Research/Content/Short-reports/*pptx/
同时仍包括所有其他文件夹:
/Research/Content/Short-reports/
Geta 似乎忽略了我的通配符并将其视为文字文本。
TIA
不幸的是,Geta 只进行字符串匹配,不会处理任何 wildcard/regex。
Geta 建议您实现自己的 IContentFilter 以进行自定义过滤。
如果有问题的文件夹是 CMS 中的内容文件夹,一种选择是在全局设置中创建一个 ContentArea 属性 以保存对您希望排除的所有文件夹的引用。然后,在 IContentFilter 实现的 ShouldExcludeContent 方法中,您可以执行检查以查看内容是否是您添加到全局设置的文件夹之一的后代。
public class MyCustomSitemapContentFilter : Geta.SEO.Sitemaps.Utils.ContentFilter
{
public override bool ShouldExcludeContent(IContent content)
{
var baseEvaluation = base.ShouldExcludeContent(content);
var shouldExclude = false;
//shouldExclude = code to check if content is
// is descendant of any of the folders referenced
// in global setting property
return shouldExclude || baseEvaluation;
}
}
如何从包含文件夹内的站点地图中排除与特定模式匹配的子文件夹?
例如,我希望排除符合以下条件的所有子文件夹:/Research/Content/Short-reports/*pptx/
同时仍包括所有其他文件夹: /Research/Content/Short-reports/
Geta 似乎忽略了我的通配符并将其视为文字文本。
TIA
不幸的是,Geta 只进行字符串匹配,不会处理任何 wildcard/regex。
Geta 建议您实现自己的 IContentFilter 以进行自定义过滤。
如果有问题的文件夹是 CMS 中的内容文件夹,一种选择是在全局设置中创建一个 ContentArea 属性 以保存对您希望排除的所有文件夹的引用。然后,在 IContentFilter 实现的 ShouldExcludeContent 方法中,您可以执行检查以查看内容是否是您添加到全局设置的文件夹之一的后代。
public class MyCustomSitemapContentFilter : Geta.SEO.Sitemaps.Utils.ContentFilter
{
public override bool ShouldExcludeContent(IContent content)
{
var baseEvaluation = base.ShouldExcludeContent(content);
var shouldExclude = false;
//shouldExclude = code to check if content is
// is descendant of any of the folders referenced
// in global setting property
return shouldExclude || baseEvaluation;
}
}