After playing around with some options, what I ended up with is using the
Render method. From the Page Template's design TBB, rather than calling
RenderComponentPresentation for this specific Component Template, I pieced together the necessary
RenderContext instances. For the
PublicationTarget, I just used the existing ones from the engine. An example of something close to what I did to get the output of a presentation is as follows:
@foreach (var cp in GetComponentPresentationsByTemplate("My Dynamic CT"))
TemplatingRenderer renderer = new TemplatingRenderer();
ResolvedItem resolvedItem = new ResolvedItem(
RenderedItem renderedItem = new RenderedItem(
RenderContext renderContext = new RenderContext(cp.Component.TridionObject);
// Now that we have all of our items ready, lets render this presentation
// But uh oh... Render does not return the presentation, we'll have to grab that
// from the underlying stream...
// Reset the position of the buffer back to the start...
using (StreamReader sr = new StreamReader(renderedItem.Content))
// ... and now read the stream to the end to a string that we can output
cpOutput = sr.ReadToEnd();
Although the above snippet is done using the Razor Mediator, you'll notice that this is just the TOM.NET API. This could easily be added to a razor helper function, or even a DWT custom function for your DW templates. You can now output that dynamic component presentation directly to the page as static content. Through the
RenderContext instance, you can even set context variables if you need to pass any special information to your CT (as was my case, the CT did an extra special something if the CT was rendered in this fashion).
One important note that the
Render method does not wrap the presentation in tcdl tags, so if you want to keep those intact you'll have to add them yourself.
I'd still be interested in hearing some other solution if you guys have them!