In Articulate's Storyline product, how does one retrieve the total number of slides (or pages) in a storyfile or project?
There's not much documentation so it's kind of hard to figure out how
to query common environment values like this. If we can get the total
number of slides then we don't have to manually set a value for it.
Apparently there is none, one must manually set a variable to the total number of slides and change that value whenever the number of slides changes...
If you know PHP, you are able to count, how many files are in the folder story_content->slide. This number tells you how many slides you have in published course.
Here is one way to find the total number of slides. Live Chat with Pete told me to: "Preview your entire course, it should show something to the effect of "generating preview for slide xx of xx" ".
After plenty of reverse engineering and debugging, you can find the total number of slides viewable in a story.
If you are comfortable with a little custom JavaScript coding for a trigger:
var player = GetPlayer(); player.totalViewSlides; // this return the number you want
player.GetVar("totalViewSlides") // this returns 0 - don't use
The player runs the player.calculateTotalViewSlides method which loops through and increments the player.totalViewSlides variable. As long as the player has time to build, player.totalViewSlides is calculated and exposed.
You could set a global variable through the Triggers panel / Manage project variable button:
totalNumSlides / number / 0
Then set it with a custom JavaScript trigger:
var player = GetPlayer(); var totalNumSlides = player.totalViewSlides; player.SetVar("totalNumSlides", totalNumSlides);
Welcome to the community! I love that this type of detail and help is your first post! Hope we'll be seeing more of you around.
Not knowing entirely how you're using this set up, I did want to point out there is an easy way to find out the total number of slides just as a basic number. If you look at publishing to LMS, one of the tracking options is by slides viewed and you'll be able to choose out of the total number of slides as you see in this screenshot. Now that's super basic - and if you're doing some more custom display based on what slide the user is viewing at that time out of X number of slides - Javascript is definitely the way to go!
Thanks again for sharing - and feel free to let us know if you need anything else.
I'm not sure if Michael is still subscribed here, as the post is a bit older - but you could always use the "contact me" button on a ELH users' profile to reach out to them directly!
Let me know if there is anything I can help with (outside of the Javascript - as we don't offer support for it)!
What version of Storyline are you using? With Storyline 3 and Storyline 360, we have changed how the HTML5 and Flash publishing occurred and I know that's caused some differences with previous Javascript code in connection with the player.
I'm not sure if Michael is still subscribed here, but you are certainly welcome to reach out to the user directly via the 'Contact Me' option on the user profile if you do not hear back soon.
Hi Guru! Do you need to show your learners a slide counter, or do you need to figure out how many slides you have authored? This discussion provides a user-created solution for displaying slide counts for users.
We're tracking requests for automatic slide numbering as well, so thank you for contributing!
Thanks for reply. Actually I tried to show page numbers at the bottom of the content area like 1 2 3.... So that the user can click on the page numbers and will jump from page to page at any time. So, it should be a global declaration in the master slide or in the html page using JS. But, I'm unable to get the total number of slides as well as jump to the user selected page. Is there any way to get it? and also can I jump to a particular page using JS?
Note: Some one suggested that declare a global variable and enter the total number of pages manually in it. That's fine but, need to change it at all time if add or remove slides. Every time I should be remember to change it. If I get it globally as soon as opened the app, it would be very nice to place the numbers at the bottom of the page dynamically :).
Setting up that jump to slide based on a Javascript set up is something I'll have to rely on the community to help with! It's not something we can support, but there are lots of folks here in the community who have set up similar.
Can you share a copy of your .story file here so that folks can take a look at what you have already got set up?
I found some logic to jump to the target page, but it will be jumping page by page and reach the targeted page. Seems it's very slow as I have some images and videos in many page. So, if any one suggest easy way to jump directly to the particular page, it would be nice. Kindly help.
25 Replies
Apparently there is none, one must manually set a variable to the total number of slides and change that value whenever the number of slides changes...
The most lengthy conversation on the matter seems to be found here:
In that thread they describe the need to manually define such a variable.
Hi Mark,
Thanks for updating your thread here with the link, and welcome to the community! If you need anything else please let us know!
If you know PHP, you are able to count, how many files are in the folder story_content->slide. This number tells you how many slides you have in published course.
That's interesting idea, but unfortunately we can't use PHP in our solution
HI Kamil Nowek
How i will know which is the first slide. can u tell me an idea how to identify it
Regards
Saravanan.C
Here is one way to find the total number of slides. Live Chat with Pete told me to: "Preview your entire course, it should show something to the effect of "generating preview for slide xx of xx" ".
First post here.
After plenty of reverse engineering and debugging, you can find the total number of slides viewable in a story.
If you are comfortable with a little custom JavaScript coding for a trigger:
var player = GetPlayer();
player.totalViewSlides;
// this return the number you wantplayer.GetVar("totalViewSlides")
// this returns 0 - don't useThe player runs the
player.calculateTotalViewSlides
method which loops through and increments theplayer.totalViewSlides
variable. As long as the player has time to build,player.totalViewSlides
is calculated and exposed.You could set a global variable through the Triggers panel / Manage project variable button:
totalNumSlides / number / 0
Then set it with a custom JavaScript trigger:
var player = GetPlayer();
var totalNumSlides = player.totalViewSlides;
player.SetVar("totalNumSlides", totalNumSlides);
Now you can use totalNumSlides as needed.
Hopefully this helps someone.
Hi Michael,
Welcome to the community! I love that this type of detail and help is your first post! Hope we'll be seeing more of you around.
Not knowing entirely how you're using this set up, I did want to point out there is an easy way to find out the total number of slides just as a basic number. If you look at publishing to LMS, one of the tracking options is by slides viewed and you'll be able to choose out of the total number of slides as you see in this screenshot. Now that's super basic - and if you're doing some more custom display based on what slide the user is viewing at that time out of X number of slides - Javascript is definitely the way to go!
Thanks again for sharing - and feel free to let us know if you need anything else.
Michael, the line
player.GetVar("totalViewSlides");
gives me an error
app.min.js:12 resolver::resolvePath - Path did not resolve at: totalViewSlides
thoughts?
Hi Nathan,
I'm not sure if Michael is still subscribed here, as the post is a bit older - but you could always use the "contact me" button on a ELH users' profile to reach out to them directly!
Let me know if there is anything I can help with (outside of the Javascript - as we don't offer support for it)!
Hello Nathan,
The var 'totalViewSlides' from Michael's code bit is a manual variable you set in the Manage Project Variables panel inside Storyline.
I hope this helps.
-James
It should be noted that player.totalViewSlides is available in a course published as html5, but not in the Flash version of that course.
Hi George,
What version of Storyline are you using? With Storyline 3 and Storyline 360, we have changed how the HTML5 and Flash publishing occurred and I know that's caused some differences with previous Javascript code in connection with the player.
Hello Michael,
Is your solution for Storyline 2?
Because I have tried it in Storyline 3 and I don't get the number of slides viewed.
I have undefined with:
This post was removed by the author
Hi Ludovic,
I'm not sure if Michael is still subscribed here, but you are certainly welcome to reach out to the user directly via the 'Contact Me' option on the user profile if you do not hear back soon.
Hi All,
I'm also looking for the same. Is there any way to get total number of slides at the beginning of the Scene starts? Kindly help.
Thanks,
Guru
Hi Guru! Do you need to show your learners a slide counter, or do you need to figure out how many slides you have authored? This discussion provides a user-created solution for displaying slide counts for users.
We're tracking requests for automatic slide numbering as well, so thank you for contributing!
Hi Crystal,
Have a good day!
Thanks for reply. Actually I tried to show page numbers at the bottom of the content area like 1 2 3.... So that the user can click on the page numbers and will jump from page to page at any time. So, it should be a global declaration in the master slide or in the html page using JS. But, I'm unable to get the total number of slides as well as jump to the user selected page. Is there any way to get it? and also can I jump to a particular page using JS?
Note: Some one suggested that declare a global variable and enter the total number of pages manually in it. That's fine but, need to change it at all time if add or remove slides. Every time I should be remember to change it. If I get it globally as soon as opened the app, it would be very nice to place the numbers at the bottom of the page dynamically :).
Please suggest.
Thanks,
Guru
Hi Guru,
Setting up that jump to slide based on a Javascript set up is something I'll have to rely on the community to help with! It's not something we can support, but there are lots of folks here in the community who have set up similar.
Can you share a copy of your .story file here so that folks can take a look at what you have already got set up?
Hi Ashley,
Thank you very much.
I found some logic to jump to the target page, but it will be jumping page by page and reach the targeted page. Seems it's very slow as I have some images and videos in many page. So, if any one suggest easy way to jump directly to the particular page, it would be nice. Kindly help.
Thanks,
Guru
This post was removed by the author
Hi all,
player.totalViewSlides; this works in storyline 2/3, but can you please suggest the same for articulate 360.
for 360 this code doesn't work?
please guide me
Hi Ruchi and welcome to E-Learning Heroes :)
Storyline 360 now has a feature for slide numbers, which also includes the total slides.
Check out this tutorial here.
If you decide you still need the Javascript solution, then hopefully the community will chime in to help.