简体   繁体   English

排序Ektron内容类型

[英]sort Ektron content types

Ektron 801 SP1 Ektron 801 SP1

I am using the following code to fetch some smart form content. 我正在使用以下代码来获取一些智能表单内容。 Can I pre-sort (using OrderByField?) before I fetch 20 rows? 我可以在获取20行之前进行预排序(使用OrderByField吗?)? I am sorting memberlist but that is after the fact and kinda useless. 我正在对成员列表进行排序,但这是事实之后的,有点无用。 What am I missing? 我想念什么?

Criteria<ContentProperty> criteria1 = new Criteria<ContentProperty>();
criteria1.AddFilter(ContentProperty.XmlConfigurationId, CriteriaFilterOperator.EqualTo, MEMBERS_ID);
criteria1.PagingInfo = new PagingInfo(20);

List<ContentType<member>> memberslist = contentTypeManager.GetList(criteria1);

I have good news and bad news for you. 我对你有好消息,也有坏消息。

First, the good news. 首先,好消息。 You can sort by Content Properties with the Criteria object before you pull the 20 items. 拉取20个项目之前,您可以使用“条件”对象按“内容属性”进行排序。 You'll want to use the OrderByField and OrderByDirection properties of the criteria. 您将要使用条件的OrderByField和OrderByDirection属性。

criteria.OrderByField = ContentProperty.DateCreated;
criteria.OrderByDirection = EkEnumeration.OrderByDirection.Descending;

The bad news comes when trying to order items based on fields within the Smart Form. 尝试根据智能表单中的字段订购商品时,会出现坏消息。 You might be able to do so using the IndexSearch API, but since Ektron 8.0* still relies on Microsoft's Indexing Service, I'm not a fan of that approach and don't have any code to share. 可能可以使用IndexSearch API做到这一点,但是由于Ektron 8.0 *仍然依赖于Microsoft的Indexing Service,因此我不喜欢这种方法,也没有任何代码可共享。 If you choose to go that route, the premise is to use search to return the content IDs in the correct order, then use the criteria, as you are, to get items with those IDs. 如果您选择走那条路线,那么前提是使用搜索以正确的顺序返回内容ID,然后按原样使用条件来获取具有这些ID的商品。

What you can do with just the API is use Microsoft LINQ to sort the data after it's loaded, but in order to get the right results in the right order you have to load all items first (and ideally cache them to minimize performance impact). 仅使用API 即可执行的操作是使用Microsoft LINQ对数据进行加载后的排序,但是为了以正确的顺序获得正确的结果,必须首先加载所有项目(理想情况下将其缓存以最大程度地降低性能影响)。 I'm using one of my content types as an example, but you should get the idea. 我以一种内容类型为例,但是您应该明白这一点。

var membersList = new List<SlideBannerType>();
var sortedList = membersList.OrderBy(s => s.EnableAlternateText);
var firstpage = sortedList.Take(20);
var nextpage = sortedList.Skip(20).Take(20);

It's not ideal, but it does work very well for smaller (in the hundreds, perhaps thousands, but not tens of) data sets. 它不是理想的,但是对于较小的数据集(数百个,也许是数千个,而不是几十个),它确实可以很好地工作。

The second bit of good news, though, is that Ektron uses Microsoft Search Server for versions 8.5 and up. 好消息的第二点是,Ektron将Microsoft Search Server用于8.5及更高版本。 This has a much, much more robust API and performs fantastic (both in terms of speed and reliability). 它具有强大得多的API,并且表现出色(在速度和可靠性方面)。 The premise would actually stay the same as that for the IndexSearch, use Search to get the IDs in the right order, and then ContentManager (or ContentTypeManager) to get the items. 前提实际上将与IndexSearch相同,前提是使用Search以正确的顺序获取ID,然后使用ContentManager(或ContentTypeManager)获取项。 I've used this approach several times, albeit not with Smart Forms specifically. 我已经多次使用这种方法,尽管不是专门针对Smart Forms。 Your best result would come from upgrading to 8.6 and Microsoft Search Server and using the two APIs together to get each page of data. 最好的结果将是升级到8.6和Microsoft Search Server并一起使用这两个API来获取每一页数据。 In doing so, it would actually be almost trivial at that point to mix in advanced search and filter options as well with the new search APIs. 这样做时,实际上混入高级搜索和过滤器选项以及新的搜索API几乎是微不足道的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM