public override void Process(HttpRequestArgs args) { if (!WildcardProvider.IsWildcardItem(Context.Item)) { return; } string itemName = ResolveItemNameFromUrl(args.Context); var datasourceItem = WildcardProvider.GetDatasourceItem(Context.Item, itemName); if (datasourceItem == null) { return; } args.Context.Items[AppConstants.ContextItemKey] = Context.Item; Context.Item = datasourceItem; }
protected new virtual Item ResolveItem(GetPageItemArgs args) { string path = this.GetPath(args.RouteData); if (string.IsNullOrEmpty(path)) { return(null); } Item wildcardItem = this.GetItem(path, args); if (wildcardItem == null) { return(null); } if (!wildcardItem.IsWildcardItem()) { return(wildcardItem); } ReferenceField datasourceReference = wildcardItem.Fields[AppConstants.WildcardDatasourceField]; if (datasourceReference == null || datasourceReference.TargetItem == null) { return(wildcardItem); } if (HttpContext.Current.Items.Contains(AppConstants.ContextItemKey)) { HttpContext.Current.Items[AppConstants.ContextItemKey] = wildcardItem; } else { HttpContext.Current.Items.Add(AppConstants.ContextItemKey, wildcardItem); } string itemRelativePath = StringUtil.EnsurePrefix('/', WildcardProvider.GetWildCardItemRelativeSitecorePathFromUrl(path, wildcardItem)); string itemPath = string.Concat(datasourceReference.TargetItem.Paths.FullPath, itemRelativePath); string[] pathSegments = itemPath.Split('/'); return(WildcardProvider.GetDatasourceItem(string.Join("/", pathSegments.Take(pathSegments.Length - 1)), pathSegments.LastOrDefault())); }