Add a list of wiki pages and folders
-
07-10-2020 - |
Question
I have my wiki page library files organized into folders and subfolders. I want to create a welcome page that shows this, in this sort of manner:
- Wiki
- Folder
- Subfolder
- Subfolder Page
- Folder Page
- Folder Page
- Subfolder
- Folder
And so on (the dots aren't necessary, just trying to give an idea of depth to show what I mean). Manually, I could create this, but the time and effort for upkeep would be extreme. What I would like is something like a web part that would scan the wiki page library (database or however) and populate this info in this simple manner on the welcome page. I'm using sharepoint online
Can anyone help?
La solution 2
The only way I've found that consistently works in this case is to use JSOM in a function and get a list of folders in the folder and then recursively call a function that relies on this listing, passing current path along during each recursive call.
Pseudo-code example
function getfolders(path)
{
somejsomcalls
return foldersinpath
}
function getfiles(path)
{
somejsomcalls
return filersinpath
}
function buildlist(path)
{
curfolder = somejsomtoretreivecurrentfolderinfo(path)
*add some HTML to build list*
folders = getfolders(path)
files = getfiles(path)
foreach (folder in folders)
{
buildlist(path\folder)
}
foreach (file in files)
{
*some html to add the files to list*
}
}
If needed/desired I can post an example code of what I have working, if this doesn't explain well enough. Also, if someone has a better answer, please post and I will gladly mark you as answer.
Autres conseils
you have to use JSOM to recursively call folders and pages in the folders.