Items collapse if no data, plus other issues

Hello, I am having several issues. I have no code to show at the moment because I’m very new and don’t really know where to start.

I have a client with a portfolio that I have put into the data manager and created dynamic pages.

Question 1: Can I edit pages separately if there is certain content that needs to go on one page but not another?

Question 2: If not, how do I go about collapsing elements that do not need to be shown if there is no content. Example… this whole strip contains the ‘press and awards’ section. Some of the projects have none. Some only have press.

This one below works well as it has all components I’m looking for filled in the data manger…

But this one does not have any press or awards so I do not want this section to show at all…

Question 3: Some of the articles that would go into this gallery only have 2 pages. Is there a way to center the gallery. It looks like garbage if there are only two images and they are left-justified.

Question 4: I am hoping to add some links to other publications online that do not have a visual component but how to I add text to the content manager and then link that. I do not want all the HTTP:// junk, I want to have it show ‘Lakeside Camp’ (for example) and link out. If I select URL as field type, I am only able to add a URL and not text shown.

If I need to break these out into separate questions in the forum I am happy to but it’s all the same project so it made sense to share photos etc. here. If anyone has base code for me to work from with explanation - or a better way to do all of this or present the information it is greatly appreciated. It seems the Wix Customer Care team has no knowledge that Velo even exists as they told me it is not possible to collapse items at all. Is there a Velo Customer Care team?

TIA

Hello!

I’m not a velo master or anything but I have a similar thing with collapsing on dynamic pages.

Here is the basic code I used that works for me:

$w.onReady(() => {
    $w("#database1").onReady(() => {
 // Gets the current item properties and stores them in a variable called item
 const item = $w("#database1").getCurrentItem();
 
 if (!item.FIELDNAME) {
                    $w("#ELEMENTNAME").collapse();
        }

I hope that helps!

Hi Emily, I appreciate the help… I tried to enter the code and I am getting this… (I am only working on the gallery at the moment) See the code below too. I am sorry, I am still trying to learn all of this!

$w.onReady(() => {
$w( “#dynamicDataset” ).onReady(() => {
// Gets the current item properties and stores them in a variable called item
const item = $w( “#dynamicDataset” ).getCurrentItem();

if (!awardImage) {
$w( “#gallery3” ).collapse();
}

Sorry! That’s my fault, I have a string of different things that collapse different bits so I didn’t complete out the code… see below

$w.onReady(() => { $w( " #dynamicDataset " ).onReady(() => { // Gets the current item properties and stores them in a variable called item const item = $w( " #dynamicDataset " ).getCurrentItem(); if (!awardImage) { $w( " #gallery3 " ).collapse();

}
});

1 Like

apologies for how messy that is, but basically you need to add

});

to the bottom

@emilycarabutler That seems simple enough, such a noob here. I tried it and it still doesn’t seem to be working… :frowning:

$w.onReady(() => {
$w( “#dynamicDataset” ).onReady(() => {
// Gets the current item properties and stores them in a variable called item
const item = $w( “#dynamicDataset” ).getCurrentItem();

if (!awardImage) {
$w( “#gallery3” ).collapse();
}
});

@emilycarabutler I have added ANOTHER }); and that seems to have done it. I will continue to add a couple more things… I may run into more issues haha thank you so far :slight_smile:

@emilycarabutler Hi Emily, still working on a couple of things here… are you able to take a look at this one? Now I am trying to hide a button when there is no link provided. There is no error but the button is not hiding. I tried .collapse too.

$w.onReady(() => {
$w( “#pressDataset” ).onReady(() => {
// Gets the current item properties and stores them in a variable called item
const item = $w( “#pressDataset” ).getCurrentItem();
if (!item.articleLink) {
$w( “#button6” ).hide();
}
});
});

@creative

You will be able to solve your own issues, when you will use more the CONSOLE!

$w.onReady(() => {
    $w("#pressDataset").onReady(() => {
        const item = $w("#pressDataset").getCurrentItem();
        console.log(item)
        console.log(item.articleLink)

        if (!item.articleLink) {console.log("HIDE")
            $w("#button6").hide();
        }
        else {console.log("SHOW?")}
    });
});

@russian-dima Well, I am only just learning. So I’m sorry. I’ve followed multiple threads to try to find the code I need and Wix does not help with this… I am only asking for help here so I can learn. I tried this and it isn’t working either.

@creative

Why the button should be hidden???

You have a provided link!

Your link hast to be —> EMPTY <— if you want to hide your button!

And as i already mentioned, you should work more with CONSOLE-Logs!

If you would have used this code-part here, like i showed above…

if(!item.articleLink){console.log("HIDE")$w("#button6").hide();}
else{console.log("SHOW?")}

You would surely recognize your error.

@russian-dima why are you being a jerk? I literally copy and pasted your code. THERE IS NO LINK IN MY CONTENT MANAGER !!! !! !! ! ! ! !! So if you’re going to keep being indecent, don’t even respond.

$w.onReady(() => {
$w( “#pressDataset” ).onReady(() => {
const item = $w( “#pressDataset” ).getCurrentItem();
console.log(item)
console.log(item.articleLink)

if (!item.articleLink) {console.log( “HIDE” )
$w( “#button6” ).hide();
}
else {console.log( “SHOW?” )}
});
});

@creative

No comment!

Good luck and happy coding!

Post can be closed!

Is there a solution here? I am having similar issues with things not hiding and also tried the above.

Sorry it didn’t work, it’s usually because one thing isn’t ticked or something. Here is the original post I learned it from

Sorry, I’m not at my computer, I will have a look in the AM and see if I can make it work on my editor and let you know :smiling_face:

No worries, thank you!

I got the original issue to work and was able to collapse the gallery based on your code.

I’ve now looked at that old post you referred to because he is originally asking about the button as well… I got all of the errors out but that dang button is still showing.

I found another post here https://www.wix.com/velo/forum/community-discussion/hide-repeater-contents-based-on-data regarding the button and was able to get it to work! I am not sure where to add those console.log that were mentioned above. They were mentioned here to so I will try to mess around with that.

$w.onReady(() => {
$w( ‘#repeater1’ ).onItemReady(($wInRepeater, itemData) => {
const thereIsNoarticleLink = !itemData.articleLink
if (thereIsNoarticleLink) $wInRepeater( ‘#button6’ ).collapse()
})
});

All in all, your code worked to hide my gallery. Thank you!

1 Like