Update video URL on dynamic pages

Hi spence,

You can update the video component with some code.

  1. Add the Text field to your database collection to hold the Youtube URL.

  2. Add a dataset to your dynamic page and connect all other elements the regular way.

  3. Add a Youtube video element from the Editor ‘Add Panel’ and use the following code snippet to get the video URL and set it to the video element.

$w.onReady(function () { 
    $w("#dataset1").onReady(()=>{
    let itemObj = $w("#dataset1").getCurrentItem(); 
    $w("#video1").videoUrl = itemObj.url; 
    }); 
});

The code access the dataset and the video elements by their ID. The ID (e.g. dataset1) can be found in the property panel once you select the element in the editor.

The code assumes you called the field in your collection ‘URL’ and hence the field key is ‘url’.
You can find your field key by clicking on the 3 dots icon and ‘Manage Properties’