Question:
How to correct a “empty URL” error on dynamic pages ?
Product:
Wix studio editor
What are you trying to achieve:
I want to make it easier to create a set of fairly similar pages using a CMS collection and dynamic pages. I have about sixty project pages to create, each consisting of:
Title / Subtitle / Main 16:9 video + a variable number (from 0 to 18) of additional videos with different ratios: 16:9 / 9:16 or 4:5. The videos are embedded using iframes. Following some advice, I set up a “projects” collection that references a “videos” collection.
I get the title and subtitle fine; but my problem is that when I run tests, with the following :
$w.onReady(function () {
const item = $w(“#dynamicDataset”).getCurrentItem();
if (item && item.mainVideoUrl) {
const ratio = item.mainRatio || “16:9”;
const padding = getRatioPadding(ratio);
const html = `
<div style="padding:${padding}% 0 0 0;position:relative;">
<iframe
src="${item.mainVideoUrl}"
frameborder="0"
allow="autoplay; fullscreen; picture-in-picture; clipboard-write; encrypted-media"
style="position:absolute;top:0;left:0;width:100%;height:100%;"
title="Main Video">
</iframe>
</div>
`;
$w("#htmlMainVideo").postMessage(html);
}
});
function getRatioPadding(ratio) {
switch (ratio) {
case “9:16”:
return 177.78;
case “4:5”:
return 125;
case “16:9”:
default:
return 56.25;
}
}
I get error messages like:
UserError: datasetApi ‘getCurrentItem’ operation failed
Caused by DatasetError: Operation (getCurrentItem) is not allowed because the field used to build this page’s URL is empty
My URLs are structured like this: /projects/[title]/[subtitle] and my collection is complete. The site isn’t published yet — could that be the reason?
I can’t seem to fix the issue, but I don’t want to publish the site just yet because I’m still testing and nothing is final.
What have you already tried:
Check the slug creation / Collection complete and correct.
Additional information:
It’s my first wix studio project, the potential is crazy but I’m clearly a newbie. I want to succeed !! Many thanks