//====================================================================== Model protected override object GetModel() { var contextNode = GetContextNode(); if (contextNode == null) { return(null); } var smartFolder = SmartFolder.GetRuntimeQueryFolder(); smartFolder.Query = string.Format("+InTree:\"{0}\" +TypeIs:Workspace -TypeIs:(Blog Wiki)", contextNode.Path); var content = Content.Create(smartFolder); //Get base model as Content and use some of its children definition properties. //Do not override the whole ChildrenDefinition object here because SmartFolder //has its own special children definition override. var oldc = base.GetModel() as Content; if (oldc != null) { content.ChildrenDefinition.EnableAutofilters = oldc.ChildrenDefinition.EnableAutofilters; content.ChildrenDefinition.EnableLifespanFilter = oldc.ChildrenDefinition.EnableLifespanFilter; content.ChildrenDefinition.Skip = oldc.ChildrenDefinition.Skip; content.ChildrenDefinition.Sort = oldc.ChildrenDefinition.Sort; content.ChildrenDefinition.Top = oldc.ChildrenDefinition.Top; } return(content); }
public GenericContent FetchContent() { if (_fetchContent == null && !_fetchError) { if (!string.IsNullOrEmpty(Query)) { var sf = SmartFolder.GetRuntimeQueryFolder(); sf.Query = this.Query; var c = Content.Create(sf); c.ChildrenDefinition.EnableAutofilters = this.EnableAutofilters; c.ChildrenDefinition.EnableLifespanFilter = this.EnableLifespanFilter; c.ChildrenDefinition.Skip = 0; //c.ChildrenDefinition.Sort = this.ChildrenDefinition.Sort; c.ChildrenDefinition.Top = 1; try { if (c.Children != null && c.Children.Any()) { _fetchContent = c.Children?.ToList()?.FirstOrDefault()?.ContentHandler as GenericContent; } } catch (Exception ex) { _fetchError = true; } } } return(_fetchContent); }
protected override object GetModel() { var sf = SmartFolder.GetRuntimeQueryFolder(); var model = Content.Create(sf); if (!this.AllowEmptySearch && SearchTextIsTooGeneric(this.QueryString)) { if (HttpContext.Current.Request.Params.AllKeys.Contains(QueryParameterName)) { this.ErrorMessage = SNSR.GetString(ContextSearchClass, "Error_GenericSearchExpression"); } return(model); } sf.Query = ReplaceTemplates(this.QueryString); var baseModel = base.GetModel() as Content; if (baseModel != null) { model.ChildrenDefinition = baseModel.ChildrenDefinition; model.ChildrenDefinition.PathUsage = PathUsageMode.NotUsed; if (FilterByContext) { var ctx = GetContextNode(); if (ctx != null) { //add filter: we search only under the current context var escapedPath = ctx.Path.Replace("(", "\\(").Replace(")", "\\)"); model.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(model.ChildrenDefinition.ContentQuery, ContentQuery.AddClause(sf.Query, string.Format("InTree:\"{0}\"", escapedPath), ChainOperator.And), ChainOperator.And); } } else { if (!string.IsNullOrEmpty(sf.Query)) { model.ChildrenDefinition.ContentQuery = ContentQuery.AddClause(model.ChildrenDefinition.ContentQuery, sf.Query, ChainOperator.And); } } } ResultModel = model; return(model); }
protected override object GetModel() { var sf = SmartFolder.GetRuntimeQueryFolder(); sf.Query = ReplaceTemplates(this.QueryString); var c = ContentRepository.Content.Create(sf); // Get base model as Content and use some of its children definition properties. // Do not override the whole ChildrenDefinition object here because SmartFolder // has its own special children definition override. var oldc = base.GetModel() as ContentRepository.Content; if (oldc != null) { c.ChildrenDefinition.EnableAutofilters = oldc.ChildrenDefinition.EnableAutofilters; c.ChildrenDefinition.EnableLifespanFilter = oldc.ChildrenDefinition.EnableLifespanFilter; c.ChildrenDefinition.Skip = oldc.ChildrenDefinition.Skip; c.ChildrenDefinition.Sort = oldc.ChildrenDefinition.Sort; c.ChildrenDefinition.Top = oldc.ChildrenDefinition.Top; } return(c); }