So here’s an interesting one. I’m attempting to create an item page from a database of profiles. It’s quite a simple page in terms of dynamic content (i.e. profile image, bio, external link etc.) but I also have fields for social media / other profiles (i.e. Facebook, Instagram, iTunes, Spotify, etc.) for each profile and I want to have buttons that link to those sites also.
I’ve tried adding icons to a repeater and I figured out how to define the links of the items individually but I cannot set an individual repeater item to hide.
Here’s the code for I wrote for setting the links of the icons:
$w.onReady( function () {
$w(“#dynamicDataset”).onReady(() => { //Set ‘Where to listen’ Links
$w(“#artistWhereToListen”).forItems([“item1”], ($item, itemData, index) => { //Apple Music
$item(“#listenIcon”).link = $w(“#dynamicDataset”).getCurrentItem().linkAppleMusic;
$item(“#listenIcon”).alt = “Apple Music”;
$item(“#listenIcon”).target = “_blank”;
});
$w(“#artistWhereToListen”).forItems([“item-jqklwbbo”], ($item2, itemData2, index2) => { //iTunes
$item2(“#listenIcon”).link = $w(“#dynamicDataset”).getCurrentItem().linkITunes;
$item2(“#listenIcon”).alt = “iTunes”;
$item2(“#listenIcon”).target = “_blank”;
});
$w(“#artistWhereToListen”).forItems([“item-jqklw87a”], ($item3, itemData3, index3) => { //Spotify
$item3(“#listenIcon”).link = $w(“#dynamicDataset”).getCurrentItem().linkSpotify;
$item3(“#listenIcon”).alt = “Spotify”;
$item3(“#listenIcon”).target = “_blank”;
});
$w(“#artistWhereToListen”).forItems([“item-jqklwcw5”], ($item4, itemData4, index4) => { //Google Play
$item4(“#listenIcon”).link = $w(“#dynamicDataset”).getCurrentItem().linkGooglePlay;
$item4(“#listenIcon”).alt = “Google Play”;
$item4(“#listenIcon”).target = “_blank”;
});
.
.
.
.
});
I need the icons to hide if there is no link for the icon - for each item.
I’ve tried just adding the icons each separately but that would mean that the spacing would look ‘off’ when an item is hidden.
Any suggestions?