Embedded vs Dynamic Component Presentation and the Resolving / Rendering Differences in Publish

The Component Presentations combine a Component ( Content Part ) and a Component Template, the  HTML Part , to  produce what we call rendered content which is presented to end user or displayed in a browser.

In this post, We will look into the differences in resolving and renderings of Embedded Component Presentations (let’s call it ECP…) and Dynamic Component Presentations (DCP) when both are used/inserted into a Page. We will also look into the role of Deployer here and the different ways it processes the containing DCP  and ECP in a Page.

The crux of  the whole processing  can be summarized in 2 main points: 

  1. The Dynamic Component Presentations (DCP) are Published separately from the Page and is deployed separately as well to broker database (usual case).
  2. The Page and its Embedded Component Presentations are published together as a unit and deployed as usual to file system.

DCP_3

Let’s have a more detailed look into each of these processing. We will take the interesting case of DCPs second.

We will conclude this post by reasoning on whether publishing the Page or publishing the Component will be a good idea in this case and why .

Embedded Component Presentation Processing:

The various processing are listed in the order they occur.

– Processing by the Resolve Engine

When a Page is published, the Resolve Engine identifies ( resolves ) the items which needs to be published. Here the Embedded CTs are resolved and rendered as a PART of the Page, meaning the Context for them is the Page to which they belong.

When speaking technically in terms of TOM.NET, we have below result:

Engine.PublishingContext.ResolvedItem = <The embedded Component Presentation>
Engine.PublishingContext.RenderContext.ContextItem = <The Page>
– Processing by the Render Engine

The Render Engine, renders(generates) the rendered content from each of the resolved items ( of type Embedded CPs) and wraps it  into TCDL tags and places the whole thing onto page itself.  One TCDL tag is used for each Embedded CT on the Page.

<tcdl:ComponentPresentation type="Embedded" componentURI="<Component_TCM_URI>" 
      templateURI="ComponentTemplate_URI" 
      xmlns:tcdl="http://www.tridion.com/ContentDelivery/5.3/TCDL">
      <!-- Each individual Embedded Component Presentation (rendered content ) 
           is placed here -->
</tcdl:ComponentPresentation>

The Page contains the TCDL tags of type=”Embedded” along with the rendered content wrapped in these TCDL tags.

– Processing by the Deployer

At Deployer stage, these TCDL tags  are  simply removed by the deployer and the resultant Page deployed on CDA server contains only the rendered content within it.

Let’s now move on quickly to the interesting one!

Dynamic Component Presentation Processing:

The various processing are listed in the order they occur.

– Processing by the Resolve Engine

With Dynamic CTs on page, The Resolve Engine, responsible for resolving (identifying) the items to be published, marks the dynamic Component Presentation as a SEPARATE item to be Rendered and Published separately from the Page.

When speaking technically in terms of TOM.NET, we have below result:

Engine.PublishingContext.ResolvedItem = <The Dynamic Component Presentation>
Engine.PublishingContext.RenderContext.ContextItem = null
– Processing by the Render Engine

Next, The Render Engine, responsible for rendering the Published Items, processes the Page and for any Dynamic CTs present in Page, places a corresponding TCDL tag onto the Page:

 <tcdl:ComponentPresentation type="Dynamic" componentURI="<Component_TCM_URI>" 
       templateURI="ComponentTemplate_URI" 
       xmlns:tcdl="http://www.tridion.com/ContentDelivery/5.3/TCDL" />

Notice the difference here. This time the Page contains TCDL tags of type=”Dynamic” with NO rendered content contained/wrapped within the TCDL tags. This is because the Dynamic Component Presentation ( rendered content ) being marked as SEPARATE  from the Page, the rendered content will NOT be published together with the Page, but will be Published separately.

The rendered content ( Component Presentation) thus goes to the broker database(usual case).  This is very similar to the situation when we publish only the Component if it is associated with a Dynamic CT and the resultant Component Presentation goes to broker database.

– Processing by the Deployer

At the Deployer stage, deployer notices the type=”Dynamic” attribute of the TCDL tag ( present in the Page) and replaces it with below Custom Web Server Control tag, with appropriate TCM URIs.

<tridion:ComponentPresentation PageUri="tcm:235-17544-64"  
         ComponentUri="tcm:235-18720" TemplateUri="tcm:235-78026-32" />

At runtime, when the Page is loaded in a browser, the above Custom Control Tag actually makes a query to Broker database, gets the Component Presentation and places it at the position where the  tag is present. Yes you read that right, a query is being made to broker database at runtime for fetching the Component Presentations.

One question arises here is that when a Page contains a DCP, so far this is what we discussed if you are awake, then we can either Publish the Component ( the one associated with Dynamic CT ) or the Page itself  to propagate the changes on server. So, Which one will you Publish: Component or Page ?

Which one to Publish :  Page or the Component ?

The documentation says: If a Component is based on an allowed Schema that is used in a dynamic Component Template, only the dynamic Component Presentation is published. Any Components that link to the Component you publish are also republished.

Therefore, as we can see, if there are a number of other Components/Pages which link to the Component we publish, they all will get published too. This isn’t required mostly . Moreover, We will be actually placing too many items in publishing queue.

However, if we publish the Page, then as per the Documentation and the testing done in CMS at my end: If Pages include dynamic Component Presentations, dynamic Component Presentations are publishedIt doesn’t publish any extra Components/Pages. This seems a better option here as it avoids sending too many items in publishing queue.

Do share your feedback, comments on what you think about the Processing and Publishing  differences we discussed. Till then happy brainstorming…


5 thoughts on “Embedded vs Dynamic Component Presentation and the Resolving / Rendering Differences in Publish

  1. What’s the best practice? As I see there is no other option to pubish Components except as an ECP if CT is not dynamic whereas for component with dynamic CT have both option: querying broker and publishing along with page. Should we always create dynamic CT ?

    Like

    1. Hey Chakresh, A very well pointed out question.

      Creating dynamic CTs should not be based on publishing options.

      Usually the purpose of creating Dynamic Templates is to implement sort of Dynamic functionalities in websites, like Searching. We query the broker db, get the results and display to front end. In this case, on SearchResults page, we are NOT really inserting anything inside Page. Any content/Html will be queried at runtime and placed on page using appropriate placeholders. In some cases, we may need to Manipulate the HTML at runtime before displaying etc…

      For pretty static pages like Articles, we always use ECPs.

      Like

  2. Nice article, though i personally feels DCPs should be used carefully and we need to make sure before selecting and making any template as dynamic as all content based on that will be pushed to publish. May have some filtration logic (custom tbbs) to stop this extra load on CME. With DD4T and latest frameworks this is used for navigation items as well.

    Like

  3. I Do have a similar scenario in one of my projects and Just corrected my implementation following the guidelines here. It did reduced our load in publishing queue. HATS OFF TO YOU FOR THIS !!!

    I did shared this article among my project team to let them understand using DCPs in Pages and What NOT to publish.

    I seriously never worked on such minute details. Anyways at least I am learning :)

    Do keep sharing such info.

    Like

Leave a comment