/// <summary>Finds children based on the given url segments. The method supports convering the last segments into action and parameter.</summary> /// <param name="remainingUrl">The remaining url segments.</param> /// <returns>A path data object which can be empty (check using data.IsEmpty()).</returns> public virtual PathData FindPath(string remainingUrl) { if (remainingUrl == null) { return(PathDictionary.GetPath(this, string.Empty)); } remainingUrl = remainingUrl.TrimStart('/'); if (remainingUrl.Length == 0) { return(PathDictionary.GetPath(this, string.Empty)); } int slashIndex = remainingUrl.IndexOf('/'); string nameSegment = HttpUtility.UrlDecode(slashIndex < 0 ? remainingUrl : remainingUrl.Substring(0, slashIndex)); foreach (ContentItem child in GetChildren(new NullFilter())) { if (child.IsNamed(nameSegment)) { remainingUrl = slashIndex < 0 ? null : remainingUrl.Substring(slashIndex + 1); return(child.FindPath(remainingUrl)); } } return(PathDictionary.GetPath(this, remainingUrl)); }
/// <summary>Finds children based on the given url segments. The method supports convering the last segments into action and parameter.</summary> /// <param name="remainingUrl">The remaining url segments.</param> /// <returns>A path data object which can be empty (check using data.IsEmpty()).</returns> public virtual PathData FindPath(string remainingUrl) { if (remainingUrl == null) { return(PathDictionary.GetPath(this, string.Empty)); } remainingUrl = remainingUrl.TrimStart('/'); if (remainingUrl.Length == 0) { return(PathDictionary.GetPath(this, string.Empty)); } int slashIndex = remainingUrl.IndexOf('/'); string nameSegment = HttpUtility.UrlDecode(slashIndex < 0 ? remainingUrl : remainingUrl.Substring(0, slashIndex)); var child = Children.FindNamed(nameSegment); if (child != null) { remainingUrl = slashIndex < 0 ? null : remainingUrl.Substring(slashIndex + 1); return(child.FindPath(remainingUrl)); } return(PathDictionary.GetPath(this, remainingUrl)); }
public override PathData FindPath(string remainingUrl) { var path = base.FindPath(remainingUrl); if (path.IsEmpty() && !(this is LanguageRoot)) { var languageRoot = Find.ClosestOf <LanguageRoot>(this); if (languageRoot != null) { path = languageRoot.FindPath(remainingUrl); } } if (path.IsEmpty() && !(this is StartPage)) { var siteRoot = Find.ClosestOf <StartPage>(this); if (siteRoot != null) { path = siteRoot.FindPath(remainingUrl); } } if (path.IsEmpty() && !(this is LanguageIntersection)) { var languageIntersection = Find.ClosestOf <LanguageIntersection>(this); if (languageIntersection != null) { path = languageIntersection.FindPath(remainingUrl); } } if (path.IsEmpty() && remainingUrl == HttpContext.Current.Request.ApplicationPath) { return(PathDictionary.GetPath(CmsFinder.FindLanguageIntersection(), string.Empty)); } if (path.IsEmpty() && !(this is LanguageIntersection) && !(this is StartPage) && !(this is LanguageRoot)) // { path = base.FindPath("Index" + "/" + remainingUrl); } return(path); }