Connecting Gallery images to image fields in database.

Hi

[ i have 2 important questions ( see below ) ]
here are 2 types of codes (a and b).
“a”- this code not working

export function imatDataset_onReady() {
 let item = $w('#imatDataset').getCurrentItem();
 $w('#imatgallery').items = [
  {src: item.s1},
  {src: item.s2}, 
  {src: item.s3},
 ];
}

“b”- this working

$w.onReady(function imatDataset_onReady() { 
    let item = $w('#imatDataset').getCurrentItem();
    $w('#imatgallery').items = [
       {src: item.s1},
       {src: item.s2}, 
       {src: item.s3},
     ];
});

  1. First question: In the console on wix on preview i get:
    “Loading the code for the Imat (ID) page. To debug this code, open pw18x.js in Developer Tools.” → is this a problem? what does it mean and How can I correct it?

2) second question: for example - >> i want to display in the gallery max. 3 images for each item but not Necessarily/Always 3. So is there a solution for this?

because In some case item has only 2 or 1 image.
but when in the database are lass images for any item > gallery shows empty pictures boxes — and message in console -->" Wix code SDK Warning: The src parameter of item at index 1 that is passed to the items method cannot be set to null or undefined."
> > > (see screen) ________ thanks for all in advance ________

thanks

Hey
anybody here ?

The reason that b is working is cause at the time of the imatDataset_onReady the page may not ready yet and the $w(’ #imatgallery ') was not ready yet. So you try to interact with the gallery that is not ready yet.

About your questions:

  1. This is not a problematic message. Its just writing you what source you need to open in the dev mode in order to debug your code. You can find instruction on debugging in the following article: Velo: Testing and Troubleshooting Your Code | Help Center | Wix.com

  2. The way that the gallery present and number of picture is pre-Define. You can hack it with other type of gallery or using default picture that is in the color of the background. Other option is to create the thumbnail functionality by your self with slide show or other component in the editor.

10x, Erez

Hi All,

I need help with this issue.

I used this code to populate image, title and description for my image gallery (dynamic page). It works fine for preview mode, but it does not work for my live site.

Note: I have already sync-ed my sandbox and live databases. Database permission, anyone can read.

Wix Support Response:
“Upon reviewing your site, it seems that there is a Permissions Error that causing issues with rendering your content from dataset to your live site. Hence, why it renders fine in preview, but not on the live site. This is due to a conflict within the scripted code.” “… we highly recommend using the Wix Code Forum.”

$w.onReady(function () {
 let item = $w("#dynamicDataset").getCurrentItem();
 
      $w("#gallery1").items = [ 
        {src: item.image1, title: item.image_title1, description: item.image_desc1},
        {src: item.image2, title: item.image_title2, description: item.image_desc2},
        {src: item.image3, title: item.image_title3, description: item.image_desc3},
        {src: item.image4, title: item.image_title4, description: item.image_desc4},
        {src: item.image5, title: item.image_title5, description: item.image_desc5},
        {src: item.image6, title: item.image_title6, description: item.image_desc6}
      ];

});

Thanks in advance.

Regards,
Ben

Hello there,

i got the following issue

operation (getCurrentItem) not allowed on unconfigured data-set
the follwoing image might help


Please help me
thank you in advance

Hi 3shtar!

Please open a new thread, describe the issue and the way to reproduce it and some one from our team will respond soon with a solution for you.

Doron.

sure