Solved

Get all page names in course using Javascript

I feel like I'm overkilling this one.

I am currently able to get the IDs and names of the specific pages that I need to, but it involves opening every page in an iFrame to get the name and it all seems so unnecessary.

I just need to get a list of all the page names in my project without having to open them. I can find them using the ID if needed. Please tell me of a simpler way to achieve this.

Solution

Try adding a .js action at the course level with the following:


const currentPageId = VarCurrentPageID.getValue();

console.log(currentPageId);


const currentPageName = VarCurrentPageName.getValue();

console.log(currentPageName);


This should log the page ID and Name on each page load and would require you to open dev tools (console tab) to retrieve it.

Discussion (3)

I don't believe there is an easy way to do this but one idea that I batted around with a colleague last year was to insert an invisible Table of Contents on the top level of your your project & parse it yourself.

If you do give this a try we would love to hear how it goes!

Thanks, Susan. That is the rabbit hole that I started to go down. I'm new and self taught to Javascript though so it has been a challenge (the good/bad kind). I've tried diving into the "trivantis-tocs.js" but I'm not sure how to pull data from there. Any suggestions? I've tried adding a reference to the script at the top of mine, but that doesn't seem to do the trick.

Try adding a .js action at the course level with the following:


const currentPageId = VarCurrentPageID.getValue();

console.log(currentPageId);


const currentPageName = VarCurrentPageName.getValue();

console.log(currentPageName);


This should log the page ID and Name on each page load and would require you to open dev tools (console tab) to retrieve it.