2

I want to send the page content via SDL API based on the taxonomies similar to what we can do with the dynamic components.

Hence, could you please provide some pointers on the following:

  1. Is it possible to tag the pages with some custom metadata where the metadata itself will be fetched from an external system?
  2. Can we leverage OOB content API to query the pages based on the metadata?

We are on Tridion Sites 9.0 / DXA 2.0

Thanks in advance

2

You can use the Public Content API available through GraphQL and query pages based on metadata in the Content Data Store. The documentation for the Public Content API is available here.

Just tag the page with keywords through a page metadata schema and use a GraphQL query to fetch pages that have specific keywords. For instance, say you want to fetch page IDs tagged with keywords 010 News and 020 Further Information, a query like so would get those IDs:

{
  items(
    filter: {
      itemTypes: [PAGE],
      and: [
        { keyword: { categoryName: "Sitemap [Navigation]", key: "010 News"}},
        { keyword: { categoryName: "Sitemap [Navigation]", key: "020 Further Information"}},
      ]
    }
  )
  {
    edges {
      node {
        itemId
        publicationId
        title
        ... on Page {
          url
        }
      }
    }
  }
}

Once you have the page IDs, you can get the CPs from those IDs through a query like so:

{
  page(namespaceId: 1, publicationId: 5, pageId: 341) {
    itemId
    title
    url
    containerItems {
      ... on ComponentPresentation {
        itemId
        component {
          itemId
          title
          multiMedia
        }
      }
    }
  }
}

And the output would be something like this:

{
  "data": {
    "page": {
      "itemId": 341,
      "title": "Example News 1",
      "url": "/articles/news/news1.html",
      "containerItems": [
        {
          "itemId": -1,
          "component": {
            "itemId": 282,
            "title": "Example News 1",
            "multiMedia": false
          }
        }
      ]
    }
  }
}

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.