Skip to content

Commit 378a700

Browse files
committed
Merge branch 'staging'
2 parents 2c96e39 + 4202729 commit 378a700

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

docs/spfx/extensions/get-started/using-page-placeholder-with-extensions.md

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Using page placeholders from Application Customizer (Hello World part 2)
22

3-
>**Note:** The SharePoint Framework Extensions are currently in preview and is subject to change. SharePoint Framework Extensions are not currently supported for use in production environments.
3+
>**Note:** The SharePoint Framework Extensions are currently in preview and are subject to change. SharePoint Framework Extensions are not currently supported for use in production environments.
44
5-
Application Customizers also support you to access well known locations in the page, which you can modify based on your business and functional requirements. Typical scenarios would be for example dynamic header and footer experiences, which would be visible cross all the pages in SharePoint Online.
5+
Application Customizers also provide access to well known locations in the page, which you can modify based on your business and functional requirements. Typical scenarios would be dynamic header and footer experiences, which would be visible across all the pages in SharePoint Online.
66

7-
This is similar model as using UserCustomAction collection in Site or Web object to associate custom JavaScript, which would be used to modify page experience. Key different or advantage with SPFx extensions is that you will have guaranteed elements in the page also in case of any html dom structure modifications with future changes in SharePoint Online.
7+
This model is similar to using a UserCustomAction collection in a Site or Web object to associate custom JavaScript to modify the page experience. The key difference or advantage with SPFx extensions is that you have guaranteed elements on the page regardless of any HTML/DOM structure modifications in future changes to SharePoint Online.
88

9-
In this article, we'll continue extending hello world extension built in the previous article [Build your first SharePoint Framework Extension (Hello World part 1)](./build-a-hello-world-extension.md) to take advantage of the page placeholders.
9+
In this article, we'll continue extending the hello world extension built in the previous article [Build your first SharePoint Framework Extension (Hello World part 1)](./build-a-hello-world-extension.md) to take advantage of the page placeholders.
1010

11-
## Get access to page placeholders
11+
## Getting access to page placeholders
1212

13-
Application Customizer extensions are supported with `Site`, `Web` and `List` scopes. You can control the scope by deciding where or how the Application Customizer will be registered in our SharePoint tenant. When Application Customizer exists in the scope and is being rendered, you use following method in the code to get access on placeholder. Once you have received the placeholder object, you have full control on deciding what will be presented for end users.
13+
Application Customizer extensions are supported with `Site`, `Web` and `List` scopes. You can control the scope by deciding where or how the Application Customizer will be registered in your SharePoint tenant. When the Application Customizer exists in the scope and is being rendered, you can use the following method to get access to the placeholder. Once you have received the placeholder object, you have full control over what will be presented to the end user.
1414

15-
Notice that we are requesting well-known placeholder by using their well known identifier. In this case code is accessing header section of the page using `PageHeader` identifier.
15+
Notice that we are requesting a well-known placeholder by using the corresponding well-known identifier. In this case, the code is accessing the header section of the page using the `PageHeader` identifier.
1616

1717
```ts
18-
// Handling header place holder
18+
// Handling the header placeholder
1919
if (!this._headerPlaceholder) {
2020
this._headerPlaceholder = this.context.placeholders.tryAttach(
2121
'PageHeader',
@@ -25,11 +25,11 @@ Notice that we are requesting well-known placeholder by using their well known i
2525
}
2626
```
2727

28-
In following steps, we'll modify previously created hello word Application Customizer to access placeholders and to modify their content by adding custom html elements to them.
28+
In the following steps, we'll modify the previously created hello word Application Customizer to access placeholders and modify their content by adding custom html elements to them.
2929

30-
Switch to Visual Studio code (or your preferred IDE) and open **src\extesions\helloWorld\HelloWorldApplicationCustomizer.ts.**
30+
Switch to Visual Studio Code (or your preferred IDE) and open **src\extensions\helloWorld\HelloWorldApplicationCustomizer.ts.**
3131

32-
Add the `Placeholder` to the import section from `@microsoft/sp-application-base` by updating import as follows:
32+
Add the `Placeholder` to the import from `@microsoft/sp-application-base` by updating the import statement as follows:
3333

3434
```ts
3535
import {
@@ -38,19 +38,21 @@ import {
3838
} from '@microsoft/sp-application-base';
3939
```
4040

41-
Add also following imports under the `strings` import on top of the file:
42-
* We will create style definitions for the output in following steps
41+
Also add the following import statements after the `strings` import at the top of the file:
42+
43+
* We will create style definitions for the output in the following steps
4344
* `escape` is used to escape Application Customizer properties
4445

4546
```ts
4647
import styles from './AppCustomizer.module.scss';
4748
import { escape } from '@microsoft/sp-lodash-subset';
4849
```
4950

50-
Create a new file call **AppCustomizer.module.scss** under **src\extesions\helloWorld** folder.
51+
Create a new file named **AppCustomizer.module.scss** under the **src\extensions\helloWorld** folder.
5152

5253
Update **AppCustomizer.module.scss** as follows:
53-
* These are the styles used to output html for the header and footer placeholders.
54+
55+
* These are the styles that will be used within the outputed html for the header and footer placeholders.
5456

5557
```css
5658
.app {
@@ -77,9 +79,9 @@ Update **AppCustomizer.module.scss** as follows:
7779

7880
```
7981

80-
Move back to **HelloWorldApplicationCustomizer.ts** and update **IHelloWorldApplicationCustomizerProperties** interface to have specific properties for Header and Footer as follows.
82+
Move back to **HelloWorldApplicationCustomizer.ts** and update the **IHelloWorldApplicationCustomizerProperties** interface to have specific properties for Header and Footer as follows.
8183

82-
* If your command set uses the ClientSideComponentProperties JSON input, it will be deserialized into the BaseExtension.properties object. You can define an interface to describe it.
84+
* If your command set uses the ClientSideComponentProperties JSON input, it will be deserialized into the `BaseExtension.properties` object. You can define an interface to describe it.
8385

8486
```ts
8587
export interface IHelloWorldApplicationCustomizerProperties {
@@ -88,7 +90,7 @@ export interface IHelloWorldApplicationCustomizerProperties {
8890
}
8991
```
9092

91-
Add following private variable inside of the **HelloWorldApplicationCustomizer** class. In this scenario, these could be also local variables in a `onRender` method, but if you'd want to share that to other objects, you'd define that as private variables.
93+
Add the following private variables inside of the **HelloWorldApplicationCustomizer** class. In this scenario, these could just be local variables in an `onRender` method, but if you want to share them with other objects you define them as private variables.
9294

9395
```ts
9496
export default class HelloWorldApplicationCustomizer
@@ -103,8 +105,8 @@ Update the `onRender` method with the following code:
103105
104106
* We use `this.context.placeholders.tryAttach` to get access on the placeholder
105107
* Extension code should not assume that the expected placeholder is available
106-
* Code expects a custom property called `Header`and `Footer`. If properties exist, they will be rendered inside of the placeholder.
107-
* Notice that code path for both header and footer is almost identical in the below method, only different is the used variables and style definitions.
108+
* The code expects custom properties called `Header`and `Footer`. If the properties exist, they will be rendered inside of the placeholders.
109+
* Notice that the code path for both the header and the footer is almost identical in the below method. The only differences are the variables used and the style definitions.
108110
109111
```ts
110112
@override
@@ -114,7 +116,7 @@ Update the `onRender` method with the following code:
114116
console.log('Available placeholders: ',
115117
this.context.placeholders.placeholderNames.join(', '));
116118

117-
// Handling header place holder
119+
// Handling the header placeholder
118120
if (!this._headerPlaceholder) {
119121
this._headerPlaceholder = this.context.placeholders.tryAttach(
120122
'PageHeader',
@@ -124,7 +126,7 @@ Update the `onRender` method with the following code:
124126

125127
// The extension should not assume that the expected placeholder is available.
126128
if (!this._headerPlaceholder) {
127-
console.error('The expected placeholder was not found.');
129+
console.error('The expected placeholder (PageHeader) was not found.');
128130
return;
129131
}
130132

@@ -145,7 +147,7 @@ Update the `onRender` method with the following code:
145147
}
146148
}
147149

148-
// Trying footer placeholder
150+
// Handling the footer placeholder
149151
if (!this._footerPlaceholder) {
150152
this._footerPlaceholder = this.context.placeholders.tryAttach(
151153
'PageFooter',
@@ -155,7 +157,7 @@ Update the `onRender` method with the following code:
155157

156158
// The extension should not assume that the expected placeholder is available.
157159
if (!this._footerPlaceholder) {
158-
console.error('The expected placeholder was not found.');
160+
console.error('The expected placeholder (PageFooter) was not found.');
159161
return;
160162
}
161163

@@ -179,7 +181,7 @@ Update the `onRender` method with the following code:
179181

180182
```
181183
182-
Add following method under the `onRender` method. In this case we simply output a console message, when extension is removed from the page.
184+
Add the following method after the `onRender` method. In this case, we simply output a console message, when the extension is removed from the page.
183185
184186
```ts
185187
private _onDispose(): void {
@@ -188,11 +190,11 @@ Add following method under the `onRender` method. In this case we simply output
188190

189191
```
190192
191-
Code is now ready to be tested in SharePoint Online.
193+
The code is now ready to be tested in SharePoint Online.
192194
193195
Switch to the console window that is running `gulp serve` and check if there are any errors. If there are errors, gulp reports them in the console and you will need to fix them before proceeding.
194196
195-
If you don't have solution running currently, execute following command and ensure that you don't have any errors.
197+
If you don't have the solution running currently, execute the following command and ensure you don't have any errors.
196198
197199
```
198200
gulp serve --nobrowser
@@ -203,24 +205,24 @@ Navigate to an out of the box modern list in SharePoint Online. This can be a li
203205
To test your extension, append the following query string parameters to the URL:
204206
205207
* Notice that the GUID used in this query parameter has to match on the ID attribute of your Application Customizer available from **HelloWorldApplicationCustomizer.manifest.json**.
206-
* We also use Header and Footer JSON properties to provide parameters or configurations to the Application Customizer. In this case we simply output these values, but you could adjust the behavior based on the properties in actual production usage.
208+
* We also use Header and Footer JSON properties to provide parameters or configurations to the Application Customizer. In this case, we simply output these values, but you could adjust the behavior based on the properties in actual production usage.
207209
208210
```
209211
?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"5fc73e12-8085-4a4b-8743-f6d02ffe1240":{"___location":"ClientSideExtension.ApplicationCustomizer","properties":{"Header":"Header area of the page","Footer":"Footer area in the page"}}}
210212
```
211-
Full URL to request would be something like following:
213+
The full URL to request would be something like the following:
212214
213215
```
214216
contoso.sharepoint.com/Lists/Contoso/AllItems.aspx?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"5fc73e12-8085-4a4b-8743-f6d02ffe1240":{"___location":"ClientSideExtension.ApplicationCustomizer","properties":{"Header":"Header area of the page","Footer":"Footer area in the page"}}}
215217
```
216218
217219
![Allow Debug Manifest question from the page](../../../../images/ext-app-debug-manifest-message.png)
218220
219-
Click "**Load debug scripts**" button to continue loading scripts from your local host.
221+
Click the "**Load debug scripts**" button to continue loading scripts from your local host.
220222
221-
You should now see the alert message in your page.
223+
You should now see the custom header and footer content in your page.
222224
223225
![Custom header and footer elements rendered in the page](../../../../images/ext-app-header-footer-visible.png)
224226
225227
## Next steps
226-
Congratulations on building your own custom header and footer from Application Customizer. You can continue building out your Hello World Extension in the next topic [Deploy your extension to site collection (Hello world part 3)](./serving-your-extension-from-sharepoint.md). You will learn how to deploy and preview the Hello World extension in SharePoint site collection without using **Debug** query parameters.
228+
Congratulations on building your own custom header and footer using the Application Customizer! You can continue building out your Hello World Extension in the next topic [Deploy your extension to site collection (Hello world part 3)](./serving-your-extension-from-sharepoint.md). You will learn how to deploy and preview the Hello World extension in a SharePoint site collection without using **Debug** query parameters.

0 commit comments

Comments
 (0)