Copy link to clipboard
Copied
Hello,
I'm creating a new template and I want to include the name of the previous and next slide for the navigation. (See the image)
Is there a way to define that as a variable (I found only a variable for current slide)? Or any other workaround?
Thanks a lot!
Also, if you are going to go the route of external JavaScript you might as well use the lside enter listener and just have it happen behind the scenes. You would never have to use any action in Captivate then. You could even show and hide the text caption that holds the variable.
window.addEventListener( 'moduleReadyEvent', function( event )
{
interfaceObj = event.Data;
eventEmitterObj = interfaceObj.getEventEmitter();
initializeEventListeners();
});
function initializeEventListeners()
{
if ( inte
Copy link to clipboard
Copied
I am not aware of a system varialbe storing that information. Have an idea about a workaround, will first try it out and create an article if it works. Maybe the JS experts will have another proposal?
Copy link to clipboard
Copied
What did you think? Maybe I can try testing it?
Copy link to clipboard
Copied
I will not answer your question here for two reasons
Copy link to clipboard
Copied
I understand!
Copy link to clipboard
Copied
It doesn't look good, suspect the same bug is back as in CP2017 first release: navigation and micronavigation within an advanced action is messed up. Nothing is logical in the execution: navigation to a previous slide to store its label in a variable results in filling that var with the label of the next slide which I never visited. Sighing..... I will spend one hour more trying to find more workarounds, and test my other blog posts about micronavigation in his new release to confirm the bug. Sorry....
Copy link to clipboard
Copied
can you send me the link to the blogpost? I want to try to test with version 2019
Copy link to clipboard
Copied
I did test in CP2019. GO with JS, until the bug is solved with the advanced actions. It works perfectly for SWF output, but not for HTML output, same as in first release of CP2017.
Copy link to clipboard
Copied
This might just be one of those cases where JavaScript can help.
You can create an array of slide names and display the previous and next names on your slide. The array would have to be created manually after you know all of the names (unless someone knows how to parse the project to get all slide names).
1. Create 2 variables in your Captivate project: v_prevSlide and v_nextSlide
2. After publishing, paste this code into index.html just before the last </script> tag (change the slide names to your real slide names):
var slideNames = ['Slide1Name','Slide2Name','Slide3Name','Slide4Name'];
function getPrevNextSlides(){
var currentSlide = window.cpAPIInterface.getCurrentSlideIndex();
currentSlide -= 1; //getCurrentSlideIndex returns first slide as 1
if(currentSlide > 0){ //not on first slide - can output prev slide name
window.v_prevSlide = slideNames[currentSlide - 1];
}else{window.v_prevSlide = "";} // on the first slide - there is no prev slide, so make the name null
if(currentSlide < slideNames.length - 1){ //not on last slide - can output next slide name
window.v_nextSlide = slideNames[currentSlide + 1];
}else{window.v_nextSlide = "";} //on the last slide - there is no next slide, so make the name null
}
3. On every slide, have an On Enter Execute Javascript:
getPrevNextSlides();
4. Your text captions that display the prev and next slide names refer to v_prevSlide and v_nextSlide
Copy link to clipboard
Copied
Create 2 variables, previousLabel and nextLabel. You could create an Advanced Action and execute on Slide Enter of every slide or just execute the simple action on every slide. I prefer an Advanced Action. But just execute this JavaScript either way:
var getSlides = cp.model.data.project_main.slides.split(",");
var idx = Number(window.cpInfoCurrentSlide);
if ( idx === 1 )
{
window.previousLabel = "";
window.nextLabel = cp.D[getSlides[idx]].lb;
}
else if ( idx === window.cpInfoSlideCount )
{
window.previousLabel = cp.D[getSlides[idx-2]].lb;
window.nextLabel = "";
}
else
{
window.nextLabel = cp.D[getSlides[idx]].lb;
window.previousLabel = cp.D[getSlides[idx-2]].lb;
}
Copy link to clipboard
Copied
Aha! I knew there must be a way to parse for the slide names! Much easier than typing the whole array in.
Copy link to clipboard
Copied
Also, if you are going to go the route of external JavaScript you might as well use the lside enter listener and just have it happen behind the scenes. You would never have to use any action in Captivate then. You could even show and hide the text caption that holds the variable.
window.addEventListener( 'moduleReadyEvent', function( event )
{
interfaceObj = event.Data;
eventEmitterObj = interfaceObj.getEventEmitter();
initializeEventListeners();
});
function initializeEventListeners()
{
if ( interfaceObj )
{
if ( eventEmitterObj )
{
eventEmitterObj.addEventListener( 'CPAPI_SLIDEENTER', function ( event )
{
var getSlides = cp.model.data.project_main.slides.split(",");
var idx = Number(window.cpInfoCurrentSlide);
if ( idx === 1 )
{
window.previousLabel = "";
window.nextLabel = cp.D[getSlides[idx]].lb;
}
else if ( idx === window.cpInfoSlideCount )
{
window.previousLabel = cp.D[getSlides[idx-2]].lb;
window.nextLabel = "";
}
else
{
window.nextLabel = cp.D[getSlides[idx]].lb;
window.previousLabel = cp.D[getSlides[idx-2]].lb;
}
});
}
}
}
Copy link to clipboard
Copied
I'm afraid I didn't get that...
quite new to Captivate... and to advanced actions
Copy link to clipboard
Copied
What part don't you get?
Copy link to clipboard
Copied
use the lside enter listener , what does it mean and where do I configure that in the UI?
Copy link to clipboard
Copied
It works perfectly!
Thank you!