Gallery on a specific dynamic page

Hi,

I created a dynamic page, which will have 9 pages overall. I would like to include a gallery on only one of those pages. Could anyone help me in doing so please?

Thanks.

Hi,
you can get the current dynamic page as shown here: https://www.wix.com/corvid/reference/wix-dataset.DynamicDataset.html#getCurrentPageIndex
Set the gallery collapsed on load on a dynamic page.
If the current page index is equal to the one you wish to display the gallery on, then expand() it.
Please see the relevant references:
https://support.wix.com/en/article/corvid-working-with-the-properties-panel
https://www.wix.com/corvid/reference/$w.Gallery.html#expand

Thank you for your reply.

This makes sense, although my code does not work. At the moment this is what I have:

$w.onReady(function () {
});

export function getCurrentPageIndex(){
let pageCount=$w("#myDataset").getCurrentPageIndex();

if (pageCount === "9")
$w("#myElement").expand();
}

Does it have something to do with the onReady() function?

Thanks.