Orchardcms 选中“显示在菜单上”的页面的Orchard查询
嗨,我想做一个“查询”并设置一个过滤器,用于返回所有选中“显示在菜单上”的页面。我没有找到一种方法来做那件事。。有可能吗?试试这样的方法:Orchardcms 选中“显示在菜单上”的页面的Orchard查询,orchardcms,orchardcms-1.8,Orchardcms,Orchardcms 1.8,嗨,我想做一个“查询”并设置一个过滤器,用于返回所有选中“显示在菜单上”的页面。我没有找到一种方法来做那件事。。有可能吗?试试这样的方法: using Orchard.Localization; using Orchard.Projections.Descriptors.Filter; using Orchard.Navigation; using IFilterProvider = Orchard.Projections.Services.IFilterProvider; namespace
using Orchard.Localization;
using Orchard.Projections.Descriptors.Filter;
using Orchard.Navigation;
using IFilterProvider = Orchard.Projections.Services.IFilterProvider;
namespace MyProject.Filters
{
public class MenuPartFilter : IFilterProvider {
public Localizer T { get; set; }
public ProductPartFilter() {
T = NullLocalizer.Instance;
}
public void Describe(DescribeFilterContext describe)
{
describe.For(
"Content", // The category of this filter
T("Content"), // The name of the filter (not used in 1.4)
T("Content")) // The description of the filter (not used in 1.4)
// Defines the actual filter (we could define multiple filters using the fluent syntax)
.Element(
"MenuParts", // Type of the element
T("Menu Parts"), // Name of the element
T("Menu parts"), // Description of the element
ApplyFilter, // Delegate to a method that performs the actual filtering for this element
DisplayFilter // Delegate to a method that returns a descriptive string for this element
);
}
private void ApplyFilter(FilterContext context) {
// Set the Query property of the context parameter to any IHqlQuery. In our case, we use a default query
// and narrow it down by joining with the MenuPartRecord.
context.Query = context.Query.Join(x => x.ContentPartRecord(typeof (MenuPartRecord)));
}
private LocalizedString DisplayFilter(FilterContext context) {
return T("Content with MenuPart");
}
}
}