0

We are publishing page output in json. We are not using any DWT code to generate json. To generate json, we are doing changes at page template TBB. Json output is coming in below format.

"regions": {
   "body": [
     {
       "component": {
         "id": "tcm:182-72773-16",
         "title": "test",
         "schema": "Text",
         "content": {
           "text": [
             "<p>sample text</p>"
           ]
         },
         "metadata": {
           "embedded_global": null,
           "textalignment": null
         }
       },
       "componentTemplate": {
         "id": "tcm:223-3757-32",
         "title": "Body_Text"
       }
     }
   ]
 }

For above json, we don't see components.xml is getting generated in Transport package.

Any idea, how this components.xml is getting generated? What needs to be done to create this components.xml file?

Below is structure contain in transport package:

tcm_0-4723828-66560.Content
\Pages
\Schemas
\components.xml
\instructions.xml
\pages.xml
\schemas.xml
\transaction.xml

\components.xml is missing when publish page as json.

I have components added on page as well. In Json output, in below format we are adding component.

"component": {
      "id": "tcm:182-72773-16",
      "title": "technology",
      "schema": "Text",
      "content": {
        "text": [
          "<p>application process.</p>"
        ]
      },
      "metadata": {
        "embedded_global": null,
        "textalignment": null
      }
    },
    "componentTemplate": {
      "id": "tcm:223-3757-32",
      "title": "Body_Text"
    }

Template Building Block package output:

   <tcm:Page ID="tcm:222-163880-64" IsEditable="false" xmlns:tcm="http://www.tridion.com/ContentManager/5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<tcm:Context>
    <tcm:Publication xlink:type="simple" xlink:title="Site US English" xlink:href="tcm:0-222-1"/>
    <tcm:OrganizationalItem xlink:type="simple" xlink:title="json" xlink:href="tcm:222-155270-4"/>
</tcm:Context>
<tcm:Info>
    <tcm:LocationInfo>
        <tcm:WebDAVURL>/Home/test/devtest/json/LinkedLightBoxPage.tpg</tcm:WebDAVURL>
        <tcm:Path>\Home\test\devtest\json</tcm:Path>
        <tcm:PublishPath>\test\devtest\json</tcm:PublishPath>
        <tcm:PublishLocationPath>\json\LinkedLightBoxPage.json</tcm:PublishLocationPath>
        <tcm:PublishLocationUrl>/LinkedLightBoxPage.json</tcm:PublishLocationUrl>
    </tcm:LocationInfo>
    <tcm:BluePrintInfo>
        <tcm:OwningPublication xlink:type="simple" xlink:title="Site US English" xlink:href="tcm:0-222-1"/>
        <tcm:IsShared>false</tcm:IsShared>
        <tcm:IsLocalized>false</tcm:IsLocalized>
    </tcm:BluePrintInfo>
    <tcm:VersionInfo>
        <tcm:Version>35</tcm:Version>
        <tcm:Revision>0</tcm:Revision>
        <tcm:CreationDate>2018-04-27T13:14:25</tcm:CreationDate>
        <tcm:RevisionDate>2018-06-08T15:20:43</tcm:RevisionDate>
        <tcm:Creator xlink:type="simple" xlink:title="****" xlink:href="tcm:0-3574-65552" description="sssss  "/>
        <tcm:Revisor xlink:type="simple" xlink:title="****" xlink:href="tcm:0-3574-65552" description="ssss "/>
        <tcm:ItemLock Type="0" Title="No lock"/>
        <tcm:IsNew>false</tcm:IsNew>
        <tcm:SystemComment>Checked-in by user.</tcm:SystemComment>
        <tcm:UserComment/>
    </tcm:VersionInfo>
    <tcm:LockInfo>
        <tcm:ItemLock Type="0" Title="No lock"/>
    </tcm:LockInfo>
    <tcm:PublishInfo>
        <tcm:IsPublished>true</tcm:IsPublished>
    </tcm:PublishInfo>
    <tcm:WorkflowInfo>
        <tcm:ProcessInstance xlink:type="simple" xlink:title="" xlink:href="tcm:0-0-0"/>
        <tcm:ActivityInstance Description="" xlink:type="simple" xlink:title="" xlink:href="tcm:0-0-0"/>
        <tcm:Assignee xlink:type="simple" xlink:title="" xlink:href="tcm:0-0-0" description=""/>
        <tcm:Performer xlink:type="simple" xlink:title="" xlink:href="tcm:0-0-0" description=""/>
        <tcm:CreationDate/>
        <tcm:StartDate/>
        <tcm:FinishDate/>
        <tcm:PreviousMessage>
        </tcm:PreviousMessage>
        <tcm:AssignmentDate/>
        <tcm:DueDate/>
    </tcm:WorkflowInfo>
    <tcm:AllowedActions>
        <tcm:Actions Allow="73736" Deny="268487655" Managed="0" AllowedActions="tcm:View,tcm:Copy,tcm:HistoryList" DeniedActions="tcm:Publish,tcm:UnPublish,tcm:Edit,tcm:Delete,tcm:Classification,tcm:Localize,tcm:Unlocalize,tcm:Cut,tcm:Promote,tcm:Demote,tcm:CheckOut,tcm:CheckIn,tcm:UndoCheckOut,tcm:RePublish"/>
    </tcm:AllowedActions>
</tcm:Info>
<tcm:Data>
    <tcm:Title>LinkedLightBoxPage</tcm:Title>
    <tcm:FileName>LinkedLightBoxPage</tcm:FileName>
    <tcm:PageTemplate IsInherited="false" xlink:type="simple" xlink:title="test Page (Enhanced)" xlink:href="tcm:222-163372-128"/>
    <tcm:ComponentPresentations>
        <tcm:ComponentPresentation>
            <tcm:Component xlink:type="simple" xlink:title="assistive-technology" xlink:href="tcm:222-72773"/>
            <tcm:ComponentTemplate xlink:type="simple" xlink:title="Body_Text" xlink:href="tcm:222-3757-32"/>
            <tcm:Conditions/>
        </tcm:ComponentPresentation>
        <tcm:ComponentPresentation>
            <tcm:Component xlink:type="simple" xlink:title="222_LinkedLightBoxPage" xlink:href="tcm:222-163881"/>
            <tcm:ComponentTemplate xlink:type="simple" xlink:title="NavigationCT" xlink:href="tcm:222-5332-32"/>
            <tcm:Conditions/>
        </tcm:ComponentPresentation>
    </tcm:ComponentPresentations>
    <tcm:ApprovalStatus xlink:type="simple" xlink:title="Undefined" xlink:href="tcm:0-0-0"/>
    <tcm:MetadataSchema xlink:type="simple" xlink:title="Page (test Page Enhanced)" xlink:href="tcm:222-135069-8"/>
    <tcm:Metadata>
        <Metadata xmlns="uuid:dd6cbf29-0901-4833-92c1-a048e90615cd">
            <page_header_display>Page Header Display</page_header_display>
            <embedded_global>
                <nav_page_title>This is linked lightbox page</nav_page_title>
                <nav_page_header>This is linked lightbox page header</nav_page_header>
                <page_description>This is linked page description</page_description>
                <page_type>None</page_type>
                <seo_sitemap>SEO Sitemap</seo_sitemap>
                <seo_sitemap_type>SEO Primary Sitemap</seo_sitemap_type>
                <default_url>/test/devtest/json/LinkedLightBoxPage</default_url>
                <canonical_tag>/test/devtest/json/LinkedLightBoxPage/</canonical_tag>
                <robots>index, follow</robots>
                <lightbox_overlayheight>350</lightbox_overlayheight>
                <lightbox_overlaywidth>500</lightbox_overlaywidth>
                <lightbox_overlayprint>LightBox/Overlay Print</lightbox_overlayprint>
            </embedded_global>
            <page_variation>test Narrow</page_variation>
            <primary_region_backgroundcolor>Theme 12</primary_region_backgroundcolor>
            <body_region>
                <background_color>Theme 12</background_color>
            </body_region>
            <bottom_region>
                <background_color>Theme 12</background_color>
            </bottom_region>
        </Metadata>
    </tcm:Metadata>
    <tcm:RegionSchema xlink:type="simple" xlink:title="" xlink:href="tcm:0-0-0"/>
    <tcm:Regions/>
</tcm:Data>

  • 1
    You need components in a page for components.xml to exist. Changing the page or the template won’t generate it. – Nuno Linhares Jun 7 '18 at 20:11
  • I have components added on page as well. In Json output , in below format we are adding component. "component": { "id": "tcm:182-72773-16", "title": "technology", "schema": "Text", "content": { "text": [ "<p>Acessible grant application process.</p>" ] }, "metadata": { "embedded_global": null, "textalignment": null } }, "componentTemplate": { "id": "tcm:223-3757-32", "title": "Body_Text" } – Vivek Jun 7 '18 at 21:11
  • Does Tridion looks for specific tag for components to create components.xml? – Vivek Jun 7 '18 at 21:15
  • I am not sure whether it has any relation to "@@RenderComponentPresentation()@@" , we are not using this anywhere in component template or page template to generate JSON. We don't need component presentation as we are passing only content in json. – Vivek Jun 7 '18 at 21:32
  • Well, you're not using DWT so that call wouldn't apply. Describe the Page you're publishing--does it have Component Presentations on it directly and are their templates dynamic? What does Template builder show you in the Package as you step through your Template Building Blocks? – Alvin Reyes Jun 8 '18 at 1:25
2

I think the problem may lie in that you have to explicitly add (rendered) Component Presentations as "Child Rendered Items" to the Rendered Item of the Page, otherwise at least CD Component Linking will not work properly (and maybe you indeed don't get a components.xml at all).

See, for example, this piece of DXA 2.0 templating code (search for childRenderedItem): https://github.com/sdl/dxa-content-management/blob/master/Sdl.Web.Tridion.Templates.R2/Data/DefaultModelBuilder.cs

Again, note that DXA 2.0 TBBs produce JSON that is quite similar to what you're looking for and already take care of intricacies like this one. I would recommend using the DXA 2.0 TBBs or the entire DXA 2.0 Framework for that matter.

0

Forgive me if I miss something, it's been awhile. Why do you need the Components.xml file?

Dynamic Component Presentations

Yes, rendering a Component Presentation from a template will add that Component to the package, independent of what's on the page. The use case is wanting to add some re-used header or footer content to every page.

As a good practice, these independent Component Presentations might be "dynamic," meaning its Component Template is set to publish dynamically. Editors can then publish this Dynamic Component Presentation (DCP) independent of the page. And when publishing the page, only a reference is included (tcdl tag) in the outputted XML, which is processed in delivery.

As far as I understand, any (tcdl) tags, controls, or markup in the Page, Component, or Components don't directly control what ends up in the package. That logic is up to the template. For example, the Default Finish Actions has a TBB to look for image references and add them to the package.

Learn more about the Package or Template Builder.

See my post on static pages, Dynamic Component Presentations, and Dynamic Embedded Component Presentations or @WillPrice's piece on when to make a Component Template "Dynamic."

RenderComponentPresentation()

You don't need a DWT Template Building Block for this, though. This could be in a C# or other TBB depending on your CM-side templating. Even when "outputting JSON" there's always a CM-side template (building block).

Resolving

The default resolving logic for a Page, when you queue a Page for publishing, includes the Page itself (rendering content embedded into it) as well as any DCPs embedded into the Page.

If you have a DCP embedded on the page it should automatically be included in the Package. Note that you can't tell they're DCPs from the Page, this depends on Template settings.

See my other post on these resolving rules for background.

I've never really done much with the Transport Package directly. It's historically been an unsupported format, so I'm not sure why you really need the Components.xml file. I believe the items in the Template's Package end up in the package, maybe after a bit more processing (CM-side Renderers?).

tl;dr: Looking at your Page and template setup and running Template Builder should help you resolve or adjust your setup.

  • I am having issue with component linking. When I publish page in json, I don't see records going in "Link_Info" table in Broker database. When we inspect transport package, we see components.xml is missing from package. – Vivek Jun 8 '18 at 22:53
  • I have added template building block package output for json page. I don't see any issue there. It is generating expected output. – Vivek Jun 8 '18 at 23:57
  • Does the TBB package include any of the Components on the page? This would be separate from the Page output itself. Also the Component "technology" (tcm:182-72773-16) seems to have a different Publication context than the one on the page ("assistive-technology" with ID tcm:222-72773), not sure if that matters here (perhaps you ran the template in a different Publication?). – Alvin Reyes Jun 11 '18 at 8:58
  • Yes. TBB package include components on page as well. – Vivek Jun 11 '18 at 21:00
  • Okay, I was assuming there is a relationship between the Components item in the Page's template package and the components.xml file in the transport package. See @Rick's answer as there seems to be a different mechanism that creates the linking relationships in Content Delivery. – Alvin Reyes Jul 8 '18 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.