4

Earlier when we were using DXA CTP 2, ${pageModel.meta.sitemapKeyword} would give us the Page navigation Keyword.

Since we moved to DXA 2.0, this returns no value. We are not sure if this is related to version change.

One piece of information: In the generic Page Controller, I have autowired NavigationProvider to call the get breadcrumb navigation links for other functions.

@Controller
public class GenericPageController {

    @Autowired
    private PageController pageController;

    @Autowired
    private WebRequestContext webRequestContext;

    int publicationId = 0;
    Localization localization;

    @Autowired
    private NavigationProvider navigationProvider;

    @RequestMapping(value = {"/en/**", "/ar/**"}, produces = {"text/html", "*/*"}, method = {RequestMethod.GET, RequestMethod.POST})
    public String handleGetPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
       PageModel pageModel = (PageModel) request.getAttribute("pageModel");
       pageModel = this.enrichGetPageModel(pageModel, request);
       NavigationLinks navigationLinks = navigationProvider.getBreadcrumbNavigationLinks(requestPath, localization);
       List<Link> items = navigationLinks.getItems();
....
       pageModel.getMeta().put("og:keywords" , seoKeyword); // based on my navigation links
       request.setAttribute("pageModel", pageModel);
    return view;
    }
}

@Rick, yes the navigation keyword is seen in the page json.

 "MvcData": {
    "ViewName": "WebInsidePage",
    "AreaName": "Generic"
  },
  "XpmMetadata": {
    "PageID": "tcm:27-625-64",
    "PageModified": "2018-04-09T13:46:29",
    "PageTemplateID": "tcm:27-639-128",
    "PageTemplateModified": "2018-03-29T14:18:20"
  },
  "Metadata": {
    "sitemapKeyword": {
      "$type": "KeywordModelData",
      "Id": "777"
    }
  },
  "SchemaId": "633"
}

Page template does not use RPC TBB. One template is shown below:

<CompoundTemplate xmlns="http://www.tridion.com/ContentManager/5.3/CompoundTemplate">
  <TemplateInvocation>
    <Template xlink:href="tcm:22-874-2048" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:title="Generate DXA R2 Page Model" />
    <TemplateParameters>
      <Parameters xmlns="http://www.sdl.com/web/schemas/dynamicpage" />
    </TemplateParameters>
  </TemplateInvocation>
  <TemplateInvocation>
    <Template xlink:href="tcm:22-886-2048" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:title="Default Page Template Finish Actions" />
    <TemplateParameters></TemplateParameters>
  </TemplateInvocation>
</CompoundTemplate>
7
  • I guess "DXA-CPT" is actually "DXA 2.0 CTP x"? If so, which CTP were you using? CTP 1 or 2? Apr 9, 2018 at 12:21
  • Hi Rick, thanks for responding. Yes, that's right :) We were using CTP 2.
    – Rache
    Apr 9, 2018 at 13:09
  • How does the Page JSON look if you preview the Page in the CME? Do you see a "sitemapKeyword" in the Meta ? Apr 9, 2018 at 13:22
  • Yes I can see the sitemapKeyword. I have added it to the question.
    – Rache
    Apr 10, 2018 at 6:12
  • Note that a DXA Page Model has both a Meta and a Metadata property. You are referring to the first (${pageModel.meta.sitemapKeyword} ), but it is not shown in your JSON fragment. Apr 10, 2018 at 7:00

1 Answer 1

1

I expected your Page Template to invoke the “Render Page Content” TBB, which in turn invokes the “Generate DXA R2 Page Model” TBB (with a set of parameters).

In your case, your PT invokes the “Generate DXA R2 Page Model” TBB directly and it doesn’t specify any parameter values. This results in default values being used for all parameters and as a result only the DefaultModelBuilder is used. This indeed means that PageModelData.Meta will not be set (see https://github.com/sdl/dxa-content-management/blob/master/Sdl.Web.Tridion.Templates.R2/Data/DefaultPageMetaModelBuilder.cs )

It is highly recommended to let your Page Templates invoke “Render Page Content” instead of “Generate DXA R2 Page Model” directly; this allows you to manage DXA settings centrally.

Likewise, your Component Templates should invoke “Render Component Content” instead of “Generate DXA R2 Entity Model”.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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