Forum Discussion
Dynamic Slide/Menu Names
I'm creating a course that will be viewed by both American and Canadian users. Along with that comes localized spelling. In order to ensure consistency across versions, I am using the same story file for both and including a location variable that's set when the first slide Timeline starts. I'm not having any issues getting the slide content to adapt to the localization. But, some of the slides have names that should reflect this localized spelling too. Is there a way for the Menu to display the correct slide name?
I presume it will be a JavaScript solution that I trigger immediately after assigning the variable, but I'm not sure how to build it out from there.
Hey
You are right with your idea of a JavaScript trigger, as you can use it to access (and change) the slide names in the menu.
Here is an example:
let elements = document.getElementsByClassName("linkText"); for (var i = 0; i < elements.length; i++){ elements[i].innerHTML = "New Title " + i; }
Result:
To use your specific names you probably have to access each object individually:
let elements = document.getElementsByClassName("linkText"); elements[0].innerHTML = "This is the first slide/scene name"; elements[1].innerHTML = "This is the second slide/scene name"; elements[2].innerHTML = "This is the third slide/scene name";
Let me know if it solves your problem 🙂
- CharlotteHaslerCommunity Member
Hey
You are right with your idea of a JavaScript trigger, as you can use it to access (and change) the slide names in the menu.
Here is an example:
let elements = document.getElementsByClassName("linkText"); for (var i = 0; i < elements.length; i++){ elements[i].innerHTML = "New Title " + i; }
Result:
To use your specific names you probably have to access each object individually:
let elements = document.getElementsByClassName("linkText"); elements[0].innerHTML = "This is the first slide/scene name"; elements[1].innerHTML = "This is the second slide/scene name"; elements[2].innerHTML = "This is the third slide/scene name";
Let me know if it solves your problem 🙂- HoneyTurnerCommunity Member
oh, that worked perfectly for me!
I included a bit of error trapping in it so that I could solve any issues I encountered and with a couple tweaks, I got it to work exactly how I wanted.
let elements = document.getElementsByClassName("linkText");
var jsVer = player.GetVar("version");
var jsCanada = player.GetVar("verCanada");
var jsUS = player.GetVar("verUS");
if(jsVer == jsCanada)
{
elements[2].innerHTML = "Call Centre Icon";
}
else if(jsVer == jsUS)
{
elements[2].innerHTML = "Call Center Icon";
}
else
{
elements[2].innerHTML = "JavaScript Error";
}