tridiontridion2009tridion-content-delivery

How to access transformed html page in Custom Page Deployer?


Let's say we have to access the content of our published page in a Custom Deployer. This part of the code is inside the processPage method that is in our CustomModule that extends PageDeploy class.

This way I will get the page that is being published, but content of that page will not be transformed (components that are in that page are not rendered).

public void processPage(Page page, File pageFile) throws ProcessingException {
    File file = new File(pageFile.toString());
}

If I know that I can disable cleanup of the TransportPackages in cd_deployer.conf.xml, by changing the Cleanup to false: <WorkFolder Location="C:\tridion\work" Cleanup="false"/>, I see that Tridion generates two versions of my page:

  1. root\page.html (that has unrendered content, with path pageFile.ToString())
  2. root\transformed\page.html (that has complete content - content that I want)

Why then when I create new File with the transformed page file path and read it, I get html code with even less content then the original html? Is this because in this phase of the deployment page is still not rendered and complete or...?

Thanks!


Solution

  • Is your page using Dynamic Component Presentations? If so, the Page-level HTML that is published and deployed will only contain an "include instruction" for the Component Presentation

    <tcdl:ComponentPresentation ... />
    

    The only thing that happens during deployment is that the "technology agnostic" language used during publishing/transport is translated into either a JSP tag or a ASP.NET server control include, in both cases it typically translated into something starting with tridion:ComponentPresentation.

    The HTML fragment of the Dynamic Component Presentation itself will be published separately and stored as a separate item in the configured storage.

    The complete HTML will only be composed when the page is requested (for serving to a visitor). At that stage the JSP tag library or ASP.NET server control will be invoked, read the HTML fragment for the Component Presentation from the storage and inject it into the HTML "wireframe" of the page.

    With that knowledge, it indeed explains why you can't find the HTML fragment for the Dynamic Component Presentations in your Deployer extension: the merging of the DCP fragments into the Page shell only happens when the page is requested, not when it's deployed.