Exemple #1
0
        /// <summary>
        /// Creates the and initialize page.
        /// Modifictaion: If the page is a wildcard page, start the pipeline to resolve the correct item
        /// </summary>
        /// <param name="visit">The visit.</param>
        private void CreateAndInitializePage(CurrentInteraction visit)
        {
            IPageContext empty = visit.CreatePage();

            empty.SetUrl(WebUtil.GetRawUrl());

            DeviceItem device = Context.Device;

            if (device == null)
            {
                empty.SitecoreDevice.Id   = Guid.Empty;
                empty.SitecoreDevice.Name = string.Empty;
            }
            else
            {
                empty.SitecoreDevice.Id   = device.ID.Guid;
                empty.SitecoreDevice.Name = device.Name;
            }

            Item item = Context.Item;

            if (item.IsWildcard())
            {
                //// If you are actually using wildcard items then you can throw in your pipeline to resolve it. More information can be found online ;) Referencing an old blog from an old-coworker.
                ////var wildCardItem = ResolveWildcardItemPipeline.Run(item);

                ////if (wildCardItem != null)
                ////{
                ////    item = wildCardItem;
                ////}
            }

            if (item == null)
            {
                //// This is really important for every Sitecore platform, rule out your api's in your XDB data... Need to share this with the Sitecore Community @ Achmea
                if (empty.Url.Path.StartsWith($"/{Events.Constants.API_BASEPATH}/"))
                {
                    visit.CurrentPage.Cancel();
                }

                return;
            }

            empty.SetItemProperties(item.ID.Guid, item.Language.Name, item.Version.Number);
        }
        private void CreateAndInitializePage(HttpContextBase httpContext, CurrentInteraction visit)
        {
            var empty = visit.CreatePage();

            empty.SetUrl(WebUtil.GetRawUrl());

            var device = Context.Device;

            if (device == null)
            {
                empty.SitecoreDevice.Id   = Guid.Empty;
                empty.SitecoreDevice.Name = string.Empty;
            }
            else
            {
                empty.SitecoreDevice.Id   = device.ID.Guid;
                empty.SitecoreDevice.Name = device.Name;
            }

            // Default Sitecore implementation
            var item = Context.Item;

            // If the current item is a wildcard
            if (item != null && item.IsWilcard())
            {
                // Perform a call to the logic which resolves the correct item
                var resolvedItem = this.ResolveWildcardItem(httpContext, item);

                if (resolvedItem != null)
                {
                    item = resolvedItem;
                }
            }

            // Resume the default behaviour
            if (item == null)
            {
                return;
            }

            empty.SetItemProperties(item.ID.Guid, item.Language.Name, item.Version.Number);
        }