How to get currentSceneId and currentLayoutId?

Sometime ,multiple sence or multiple layout has the same class element。

now the current layout is 1600, how to change the “.ptitle” value with currentLayout child ‘.ptitle’ ?

use jquery , not change every “.ptitle” .

var currentLayoutId = hypeDocument.currentLayoutId();
$("#"+currentLayoutId+" .ptitle").text("i am p tag content");

https://tumult.com/hype/documentation/#hypeDocument.layoutsForSceneNamed

This one is still lacking from the API but you can do the following:

var sceneElm = document.querySelector('#'+hypeDocument.documentId()+' > .HYPE_scene[style*="block"]');
sceneElm.querySelector('.ptitle').innerHTML = "I am p tag content";

You can also use the extension project and define a new function called hypeDocument.currentSceneElement und hypeDocument

Then you can do the following

hypeDocument.currentSceneElement().querySelector('.ptitle').innerHTML = "I am p tag content";

or store the scene element

var sceneElm = hypeDocument.currentSceneElement();
sceneELm.querySelector('.ptitle').innerHTML = "I am p tag content";

Then there is the special case of functions called on scene load. At least if defined in the GUI you get the scene element under the Hype function variable element. Probably still a good practice to fetch it yourself or/and assign it to a var like sceneElm just to make sure you know what your intentions where when reading the code later. Also the HypeSceneLoad event, when used in pure code has a known bug and element is not set. Should be fixed soon (hopefully, according to Tumult).

There was also the rumor or at least weak intention to extend the official API with hypeDocument.currentSceneElement or hypeDocument.getCurrentSceneElement down the line. A important command as it allows to scope the search (to the visible) as you mentioned above.

1 Like

@MaxZieb

Thans for you replay! very usefull and clear.

Mhm, this method will change all the ‘.ptitle’ , how to change the currentLayout or currentSence child ‘.ptitle’ ?

No it changes only the first occurrences. Please read up on …

And on the following …

Here is another extension that might help… This changes content based on class across the whole hypeDocument at once.

@MaxZieb

I may not describe it clearly. Please see the picture below.
only need to change the current .ptitle

Then that is the solution …

1 Like

~ Oops… I found the important!

Whoop!

@MaxZieb Thanks a lot too!

1 Like

SetContent.hype.zip (21,2 KB)

2 Likes

@MaxZieb Thanks !

I understand, ervery sence or layout has .HYPE_scene, use display property filter is very clever method.
solved!

Thanks a lot !!

1 Like