Currently, I’m looking to create a page hierarchy outside of the main ‘content’ sections as to keep it separate from other sections and to keep it with all other cross site data. I’m able to assign layouts, sublayouts, and get content back in the way that I would like to.
However, I need the content as XHTML (very simple XHTML currently) to push it through iTextSharp & Html Tidy or equivalent. Is there a pipeline or event that I would be able to hook so that I could either get most of the page or all of the page response?
I noticed the Sitecore.Layouts namespace includes Converter, DesignTimeHtml, and RuntimeHtml, the latter of which references the convertToRuntimeHtml pipeline, which seems to pass around an HtmlDocument. These seem to be pipelines relating to the WYSIWYG editor though.
If nothing as such exists, would finding all the controls on the page and then rendering them out come close to what Sitecore would render?
I’m not sure you would have the low level access you need within a Sitecore pipeline to access the rendered HTML output of a
System.Web.UI.Control, which is ultimately what a sublayout boils down to. And I am almost positive there is no Sitecore pipeline that would have the entire rendered page.From what I’ve seen while quickly looking in Reflector, the
RenderLayoutSitecore pipelines will allow you modify the process as a Sublayout Item is linked up with its user control counterpart. TheRenderingReferenceis then added toSitecore.Context.PageContext. TheSitecore.Web.UI.WebControls.Placeholderis then in charge of getting all theRenderingReferencesand calling the System.Web.UI.Control.RenderControl()` method.Being that Sitecore is calling
System.Web.UI.Control.RenderControl()on all your sublayouts and basically throwing the output to the browser, without pushing the rendered HTML through a pipeline, you may want to look at a non-Sitecore solution.You could override all of the
Render(HtmlTextWriter writer)methods on your user controls, but that is a lot of duplicate coding (unless you have a single base control?). Your best bet may be to use an ASP.NET HttpModule to do the formatting after the entire page has been generated and about to go to the client. Here is one example – http://madskristensen.net/post/A-whitespace-removal-HTTP-module-for-ASPNET-20.aspx