Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Variable for next and previous slide name

Community Beginner ,
Sep 26, 2018 Sep 26, 2018

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!

824
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Sep 26, 2018 Sep 26, 2018

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

...
Translate
Community Expert ,
Sep 26, 2018 Sep 26, 2018

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 26, 2018 Sep 26, 2018

What did you think? Maybe I can try testing it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 26, 2018 Sep 26, 2018

I will not answer your question here for two reasons

  1. I have to doulbe-check if my solution works really. Because it is linked with navigation, and the first release of CP2017 had many issues with that type of solutions. I am not testing my idea in CP2019. This workaround, if it is indeed working, may be functional in some release, not in all.
  2. I had many bad experiences in the past, where 'experts' did steal my ideas and 'sold' them as being theirs. This is very rustrating but apparently my feeling for ethics is not the same for everyone. Sorry about that. For that reason if I can get it to work, it will be published on my blog and on the portal of te eLearning community. Even then it is not a real author protection but at least I feel better.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 26, 2018 Sep 26, 2018

I understand!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 26, 2018 Sep 26, 2018

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....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 26, 2018 Sep 26, 2018

can you send me the link to the blogpost? I want to try to test with version 2019

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 26, 2018 Sep 26, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 26, 2018 Sep 26, 2018

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 26, 2018 Sep 26, 2018

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;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 26, 2018 Sep 26, 2018

Aha! I knew there must be a way to parse for the slide names! Much easier than typing the whole array in.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 26, 2018 Sep 26, 2018

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;
    }
   });
   
  }
}
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 26, 2018 Sep 26, 2018

I'm afraid I didn't get that...

quite new to Captivate... and to advanced actions

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 26, 2018 Sep 26, 2018

What part don't you get?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 26, 2018 Sep 26, 2018
LATEST

use the lside enter listener , what does it mean and where do I configure that in the UI?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 26, 2018 Sep 26, 2018

It works perfectly!

Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources