Accessing Workspace Context from outside
# package-development
c
v15 - How can I access the context of the current workspace, I am writing an extension for v15 which is coming along nicely, however I am struggle to figure out how to access the current workspace context? I have an "Entrypoint" that loads in a Header App which when clicked, loads in my extension, which is running outside of the main Umbraco frame ( i.e. so it doesn't get effected by section navigation ) Where in this setup can I access the current context? I want to be able to find out what the user is currently editing and next to be able to manipulate the data on the page. ( not the server side data ) Thanks for any help you can give 🙂
n
Hi Chris, good question. The Context API does not enable such, you have to be requesting from an element at or within to access. When thinking about such in a bigger relation, like the facts that you can have Multiple Workspace Contexts open, it makes good sense that such would require something to identify which you are looking to resolve. In relation to what page the User is editing, you may be interested in the Property DataSet within, such exists for each Variant. Meaning two are present when in Split View. But maybe thats not relevant for you case. There may be a need to know about the active Workspace from an Application Context/Global Context thing. This is not something we have at this moment, but maybe something we could implement one day. With the abilities today my recommendation would be to create a Context of your own, of the type
workspaceContext
, such is initiated on same level as any Workspace Context. For implementation details see the example implementation here: https://github.com/umbraco/Umbraco-CMS/tree/contrib/src/Umbraco.Web.UI.Client/examples/workspace-context-counter With the extension conditions you determine in which cases you like this one to appear. Then such could communicate up to your Header App, to inform it about the Workspace evt. communicate two ways. Thats up to your implementation 🙂
6 Views