|
| 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 | + |
| 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" /> |
0 commit comments