Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. string queryName= "Product";
  2. var item = _orchardServices.ContentManager.New("Query");
  3. item.As<TitlePart>().Title =queryName;
  4. _orchardServices.ContentManager.Create(item, VersionOptions.Draft);
  5. if (!item.Has<IPublishingControlAspect>() && !item.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable)
  6. _orchardServices.ContentManager.Publish(item);
  7.  
  8. var queryPart = item.As<QueryPart>();
  9. queryPart.ContentItem.ContentType = queryName;
  10. string desc =" filter for the query";
  11. string contentType = "CommonPart.ChannelID.";
  12. var filterGroupRecord = new FilterGroupRecord();
  13. var filterRecord = new FilterRecord()
  14. {
  15. Category = "CommonPartContentFields",
  16. Type = contentType,
  17. Position = 0,
  18. };
  19. filterRecord.State = "<Form><Description>" + desc + "</Description><Operator>Equals</Operator><Value>ChannelId</Value></Form>";
  20. filterGroupRecord.Filters.Add(filterRecord);
  21. queryPart.FilterGroups.Insert(0, filterGroupRecord);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement