Skip to content

Commit 8c762ed

Browse files
authored
Merge pull request #862 from mkm17/spo-faq-page-from-excel
Adds spo FAQ page sample
2 parents 0b31b01 + 4233ff6 commit 8c762ed

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
plugin: add-to-gallery
3+
---
4+
5+
# Creation of an FAQ page in SharePoint from an CSV file as the source.
6+
7+
## Summary
8+
The script creates a basic SharePoint FAQ page using collapsible sections, with CSV data as the source.
9+
10+
![Example Screenshot](assets/example.png)
11+
12+
13+
# [CLI for Microsoft 365](#tab/cli-m365-ps)
14+
15+
```powershell
16+
$m365Status = m365 status
17+
if ($m365Status -match "Logged Out") {
18+
m365 login
19+
}
20+
21+
$csvFilePath = "scripts/spo-create-sharepoint-faq-page/assets/FAQSetup.csv"
22+
$webUrl = "https://contoso.sharepoint.com/sites/TestSite"
23+
$page = "page.aspx"
24+
25+
$csvContent = Import-Csv -Path $csvFilePath
26+
$index = 1
27+
foreach ($row in $csvContent) {
28+
switch($row.BackgroundType) {
29+
"Gradient" {
30+
m365 spo page section add --pageName $page --webUrl $webUrl --sectionTemplate OneColumn --zoneEmphasis Gradient --gradientText $row.BackgroundDetails --isCollapsibleSection --collapsibleTitle $row.Question --isExpanded $row.IsExpanded
31+
}
32+
"Image" {
33+
m365 spo page section add --pageName $page --webUrl $webUrl --sectionTemplate OneColumn --zoneEmphasis Image --imageUrl $row.BackgroundDetails --fillMode Tile --isCollapsibleSection --collapsibleTitle $row.Question --isExpanded $row.IsExpanded
34+
}
35+
"Soft" {
36+
m365 spo page section add --pageName $page --webUrl $webUrl --sectionTemplate OneColumn --zoneEmphasis Soft --isCollapsibleSection --collapsibleTitle $row.Question --isExpanded $row.IsExpanded
37+
}
38+
"Strong" {
39+
m365 spo page section add --pageName $page --webUrl $webUrl --sectionTemplate OneColumn --zoneEmphasis Strong --isCollapsibleSection --collapsibleTitle $row.Question --isExpanded $row.IsExpanded
40+
}
41+
"Neutral" {
42+
m365 spo page section add --pageName $page --webUrl $webUrl --sectionTemplate OneColumn --zoneEmphasis Neutral --isCollapsibleSection --collapsibleTitle $row.Question --isExpanded $row.IsExpanded
43+
}
44+
Default {
45+
m365 spo page section add --pageName $page --webUrl $webUrl --sectionTemplate OneColumn --isCollapsibleSection --collapsibleTitle $row.Question --isExpanded $row.IsExpanded
46+
}
47+
}
48+
49+
m365 spo page text add --text $row.Answer --pageName $page --webUrl $webUrl --section $index
50+
$index++
51+
}
52+
53+
#Disconnect SharePoint online connection
54+
m365 logout
55+
```
56+
57+
[!INCLUDE [More about CLI for Microsoft 365](../../docfx/includes/MORE-CLIM365.md)]
58+
59+
***
60+
61+
## Contributors
62+
63+
| Author(s) |
64+
| ----------------------------------------- |
65+
| [Michał Kornet](https://github.com/mkm17) |
66+
67+
68+
[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
69+
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/spo-create-sharepoint-faq-page" aria-hidden="true" />
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Question,Answer,BackgroundType,BackgroundDetails,IsExpanded
2+
Question 1 - Gradient,Random answer - Gradient,Gradient,"linear-gradient(252.44deg, #1C845A 0%, #225AA0 100%)",FALSE
3+
Question 2 - Image,Random answer2 - Image,Image,https://avatars.githubusercontent.com/u/31443929?s=200&v=4,FALSE
4+
Question 3 - Strong Background,Random answer3 - Strong and expanded,Strong,,TRUE
153 KB
Loading
99.5 KB
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[
2+
{
3+
"name": "spo-create-sharepoint-faq-page",
4+
"source": "pnp",
5+
"title": "Create a basic SharePoint FAQ page",
6+
"shortDescription": "This script creates a basic FAQ page in SharePoint using a CSV file as the source.",
7+
"url": "https://pnp.github.io/script-samples/spo-create-sharepoint-faq-page/README.html",
8+
"longDescription": [
9+
"This script creates a basic FAQ page in SharePoint using a CSV file as the source. It allows you to add questions and answers with different background styles, such as gradients, images, or solid colors for strong emphasis."
10+
],
11+
"creationDateTime": "2025-07-27",
12+
"updateDateTime": "2025-07-27",
13+
"products": [
14+
"SharePoint"
15+
],
16+
"metadata": [
17+
{
18+
"key": "CLI-FOR-MICROSOFT365",
19+
"value": "10.9.0"
20+
}
21+
],
22+
"categories": [
23+
"Report"
24+
],
25+
"tags": [
26+
"m365 login",
27+
"m365 status",
28+
"m365 spo page section add",
29+
"m365 logout"
30+
],
31+
"thumbnails": [
32+
{
33+
"type": "image",
34+
"order": 100,
35+
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/spo-create-sharepoint-faq-page/assets/preview.png",
36+
"alt": "Preview of the sample spo-create-sharepoint-faq-page"
37+
}
38+
],
39+
"authors": [
40+
{
41+
"gitHubAccount": "mkm17",
42+
"company": "WM Reply",
43+
"pictureUrl": "https://github.com/mkm17.png",
44+
"name": "Michał Kornet"
45+
}
46+
],
47+
"references": [
48+
{
49+
"name": "Want to learn more about CLI for Microsoft 365 and the commands",
50+
"description": "Check out the CLI for Microsoft 365 site to get started and for the reference to the commands.",
51+
"url": "https://aka.ms/cli-m365"
52+
}
53+
]
54+
}
55+
]

0 commit comments

Comments
 (0)