Skip to content

Commit 7461b0b

Browse files
authored
Add support for ZoneReflowStrategy in Add-PnPPageSection cmdlet (#5097)
1 parent 685f59e commit 7461b0b

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

documentation/Add-PnPPageSection.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ Add-PnPPageSection -Page $page -SectionTemplate OneColumnVerticalSection -Order
6464

6565
Adds a new one column with one vertical section to the page 'MyPage' and sets the zone emphasis to 2 for one column and vertical zone emphasis to 3 for the vertical column.
6666

67+
### EXAMPLE 6
68+
```powershell
69+
$page = Add-PnPPage -Name "MyPage"
70+
Add-PnPPageSection -Page $page -SectionTemplate FlexibleLayoutSection -Order 1 -ZoneReflowStrategy LeftToRight
71+
```
72+
73+
Adds a flexible layout section to the page 'MyPage' and sets the zone reflow strategy to LeftToRight. Note: `-ZoneReflowStrategy` only applies to flexible layout section templates (for example `FlexibleLayoutSection` and `FlexibleLayoutVerticalSection`).
74+
6775

6876
## PARAMETERS
6977

@@ -142,6 +150,21 @@ Accept wildcard characters: False
142150
Sets the background of the vertical section (default = 0).
143151
Works only for vertical column layouts, will be ignored for other layouts.
144152
153+
### -ZoneReflowStrategy
154+
Controls how zones are reflowed when rendering flexible layout sections. This parameter only applies to flexible layout section templates (for example `FlexibleLayoutSection` and `FlexibleLayoutVerticalSection`). If not provided, the default is `TopToDown`.
155+
156+
```yaml
157+
Type: ZoneReflowStrategy
158+
Parameter Sets: (All)
159+
Accepted values: TopToDown, LeftToRight
160+
161+
Required: False
162+
Position: Named
163+
Default value: TopToDown
164+
Accept pipeline input: False
165+
Accept wildcard characters: False
166+
```
167+
145168
```yaml
146169
Type: Int32
147170
Parameter Sets: (All)

src/Commands/Pages/AddPageSection.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,31 @@ public class AddPageSection : PnPWebCmdlet
2121
public int Order = 1;
2222

2323
[Parameter(Mandatory = false)]
24+
[ValidateRange(0, 3)]
2425
public int ZoneEmphasis = 0;
2526

2627
[Parameter(Mandatory = false)]
28+
[ValidateRange(0, 3)]
2729
public int VerticalZoneEmphasis = 0;
2830

31+
[Parameter(Mandatory = false)]
32+
public ZoneReflowStrategy ZoneReflowStrategy = ZoneReflowStrategy.TopToDown;
33+
2934
protected override void ExecuteCmdlet()
3035
{
3136
var page = Page?.GetPage(Connection);
3237

3338
if (page != null)
3439
{
35-
page.AddSection(SectionTemplate, Order, ZoneEmphasis, VerticalZoneEmphasis);
40+
if (SectionTemplate == CanvasSectionTemplate.FlexibleLayoutSection || SectionTemplate == CanvasSectionTemplate.FlexibleLayoutVerticalSection)
41+
{
42+
// Use the user-supplied ZoneReflowStrategy when adding flexible layout sections
43+
page.AddSection(SectionTemplate, Order, ZoneEmphasis, VerticalZoneEmphasis, ZoneReflowStrategy);
44+
}
45+
else
46+
{
47+
page.AddSection(SectionTemplate, Order, ZoneEmphasis, VerticalZoneEmphasis);
48+
}
3649
page.Save();
3750
}
3851
else

0 commit comments

Comments
 (0)