Hello - I have a back office entry point that excludes an extension, but also makes a call to the Content Delivery API to get some data which is passed to some functions.
I.e.
export const onInit: UmbEntryPointOnInit = async (host, extensionsRegistry) => {
try {
let data = await getContent(host, "/umbraco/delivery/api/v2/content/item/configuration");
// Remove the Links panel from pages
extensionsRegistry.exclude('Umb.WorkspaceInfoApp.Document.Links');
// Colours
getColours(data);
// Fonts
getFonts(data);
} catch (error) {
console.log("Error getting data", error);
}
};
In my content tree I have multiple âHomeâ nodes, each of those having their own configuration files.
What I am trying to do is obtain a Site ID (the ID of the Home that is either selected / or closest parent to the current selected node).
My site set up is similar the the below.
- Site 1 (Home)
- About
- Configuration
- Site 2 (Home)
- About
- Configuration
My question is⌠Is it possible to use the context API to get ancestors of the current page?
In another one of my components I am using the UMB_ANCESTORS_ENTITY_CONTEXT, which allows access to getAncestors and returns an array of IDs, where the first item is always the âHomeâ node.
this.consumeContext(UMB_ANCESTORS_ENTITY_CONTEXT, (context) => {
if(context) {
this._siteId = context.getAncestors()[0].unique;
this._getColours(this._siteId);
}
});
I have tried using this, but the context does not exist ![]()
I.e
host.consumeContext(UMB_ANCESTORS_ENTITY_CONTEXT, (context) => {
if(context) {
console.log(context.getAncestors());
}
});
Thank you,
Rob