Beispiel #1
0
        private static void RenderContentPage(CmsPageRequest rt)
        {
            var builder         = new PageCompositionBuilder();
            var pageComposition = builder.CreatePageComposition(rt.CmsPage);

            var fragmentMode = rt.PageRenderMode == PageRenderMode.PageDesigner
                ? FragmentRenderMode.PageDesigner
                : FragmentRenderMode.Readonly;

            var cre   = new BatchingFragmentRenderer();
            var batch = cre.Execute(pageComposition, fragmentMode);

            var cache = Dependency.Resolve <CmsPageContentOutputCacheProvider>();

            foreach (var item in pageComposition.RootElement.GetAllDescendents())
            {
                if (!string.IsNullOrWhiteSpace(item.CacheKey))
                {
                    cache.AddToCache(item.CacheKey, new CachedPageContentOutput
                    {
                        InternalLayout  = (item as IHasInternalLayout)?.GetInternalLayout(),
                        RenderingResult = batch.RenderingResults[item.ContentId]
                    });
                }
            }


            var compositor = new RenderFragmentCompositor(pageComposition, batch);

            var writer = new HtmlOnlyComposedHtmlWriter();

            compositor.WriteComposedFragments(fragmentMode, writer);

            HttpContext.Current.Response.Write(writer.ToString());
        }
        public PreviewNode Page(Guid pageId)
        {
            var draft      = new CmsPageRepository().FindContentVersions(By.ContentId(pageId), ContentEnvironment.Draft).Result.Single();
            var page       = new PageCompositionBuilder().CreatePageComposition(draft);
            var cre        = new BatchingFragmentRenderer();
            var batch      = cre.Execute(page, FragmentRenderMode.PageDesigner);
            var compositor = new RenderFragmentCompositor(page, batch);
            var treeWriter = new PagePreviewWriter(draft);

            compositor.WriteComposedFragments(FragmentRenderMode.PageDesigner, treeWriter);
            return(treeWriter.RootNode);
        }