Exemple #1
0
        public object RoutePartial(BlogStartPage content, EPiServer.Web.Routing.Segments.SegmentContext segmentContext)
        {
            //Expected format is Name/<otional>Header/
            var namePart = segmentContext.GetNextValue(segmentContext.RemainingPath);

            if (!String.IsNullOrEmpty(namePart.Next))
            {
                var categoryName = HttpUtility.UrlDecode(namePart.Next);

                if (categoryName != null)
                {
                    var remaingPath = namePart.Remaining;
                    //Update RemainingPath on context.
                    segmentContext.RemainingPath = remaingPath;
                    var categoryRepository = ServiceLocator.Current.GetInstance <CategoryRepository>();
                    var category           = categoryRepository.Get(categoryName);
                    segmentContext.RoutedContentLink = content.ContentLink;

                    segmentContext.SetCustomRouteData <Category>("category", category);


                    return(content);
                }
            }

            return(null);
        }
        public object RoutePartial(BlogStartPage content, EPiServer.Web.Routing.Segments.SegmentContext segmentContext)
        {
            //Expected format is Name/<otional>Header/
            var namePart = segmentContext.GetNextValue(segmentContext.RemainingPath);

            if (!String.IsNullOrEmpty(namePart.Next))
            {
                var categoryName = HttpUtility.UrlDecode(namePart.Next);

                if (categoryName != null)
                {
                    var remaingPath = namePart.Remaining;
                    //Update RemainingPath on context.
                    segmentContext.RemainingPath = remaingPath;
                    var category = Category.Find(categoryName);
                    segmentContext.RoutedContentLink = content.ContentLink;

                    segmentContext.SetCustomRouteData <Category>("category", category);


                    return(content);
                }

                //var user = _securityHandler.GetUserByUserName(SlugDecode(namePart.Next));
                //if (user != null)
                //{
                //    var blog = _myPageHandler.GetMyPage(user).Blog;

                //    var remaingPath = namePart.Remaining;
                //    segmentContext.SetCustomRouteData<Blog>(BlogPostKey, blog);

                //    //Check if the optional Header part is present
                //    var headerPart = segmentContext.GetNextValue(namePart.Remaining);
                //    if (!String.IsNullOrEmpty(headerPart.Next))
                //    {
                //        var blogEntry = GetBlogEntry(blog, headerPart);
                //        if (blogEntry != null)
                //        {
                //            remaingPath = headerPart.Remaining;
                //            segmentContext.SetCustomRouteData<Entry>(BlogEntryKey, blogEntry);
                //        }
                //    }



                //We do not change the page which is routed to. Instead we set routed blog/entry on request
                //through SetCustomRouteData which can then be consumed from MyBlog page.
                //    return content;
                //}
            }

            return(null);
        }
        public object RoutePartial(TagPage content, EPiServer.Web.Routing.Segments.SegmentContext segmentContext)
        {
            var continentPart = segmentContext.GetNextValue(segmentContext.RemainingPath);

            if (!string.IsNullOrEmpty(continentPart.Next))
            {
                var continent = continentPart.Next;
                //Check continent exists for this category
                var mcount = SearchClient.Instance.Search <LocationItemPage>()
                             .Filter(dp => dp.TagString().Match(content.Name)).Filter(dp => dp.Continent.MatchCaseInsensitive(continent))
                             .Take(0).GetContentResult().TotalMatching;

                if (mcount == 0)
                {
                    return(null);
                }

                segmentContext.SetCustomRouteData("Continent", continent);
                segmentContext.RemainingPath = continentPart.Remaining;
                return(content);
            }
            return(null);
        }