Forum Discussion
Chivleng Tony Lim
Mar 07, 2018Copper Contributor
Get sites/<sitename> variable in SharePoint framework extension
How can I get the site name variable inside a sharepoint extension using sharepoint framework? Need to get the name of the site where the extension is deployed. Any help is appreciated. Thanks!
- Mar 07, 2018
One way is to use the PageContext object as described in the following article:
https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/connect-to-sharepoint
AFAIK the context object is also available in an Extension. The property pageContext.web.title contains the name of the site.
PnP-JS-Core also provides easy access to a lot of functionality and properties of SharePoint objects, have a look at it here:
https://github.com/SharePoint/PnP-JS-Core
paulpascha
Mar 07, 2018Bronze Contributor
One way is to use the PageContext object as described in the following article:
https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/connect-to-sharepoint
AFAIK the context object is also available in an Extension. The property pageContext.web.title contains the name of the site.
PnP-JS-Core also provides easy access to a lot of functionality and properties of SharePoint objects, have a look at it here:
https://github.com/SharePoint/PnP-JS-Core
Chivleng Tony Lim
Mar 07, 2018Copper Contributor
Great, thanks! I used this breadcrumb extension as an example.
https://github.com/SharePoint/sp-dev-fx-extensions/tree/master/samples/react-application-breadcrumb/src/extensions/siteBreadcrumb
https://github.com/SharePoint/sp-dev-fx-extensions/tree/master/samples/react-application-breadcrumb/src/extensions/siteBreadcrumb