Hoping someone might be able to help me with this… I have a real estate agent client, and we have her active listings displayed on a repeater with each field connected to dynamic content from a database. When a visitor clicks on the listing in the main gallery, it directs them to a dynamic interior page with additional images and details about that specific listing.
She would like when a property is marked ‘sold’ it still appears in the primary listings gallery so that people can see she is actively selling properties, but wants to disable any link to that property’s interior page. I can’t seem to figure out how to disable a link for one (or multiple) item in the repeater without affecting all of them.
I hope I’m articulating that clearly. Any help would be VERY much appreciated!! (website is nellesgroup.com for reference)
I just answered a similar logic question on a different post.
This is a sample of what the code would generally look like on that page with the repeater.
Let’s say you have a boolean column in your database called isSold. You would check to see if the boolean is true, if yes, then disable the item / button in that 1 repeater item. If you want all the buttons in the repeater to become disabled then you would change the $item to $w.
$w.onReady(function () {
// Dataset Connected to Repeater
$w("#dataset1").onReady(() => {
$w("#repeater").forEachItem(($item, itemData, index) => {
//Repeated Text Element
if (itemData.isSold) {
$item("#button1").disable();
}
});
});
});
Now let’s say you have the word “Sold” in a text column instead of a boolean column. (Boolean columns are easier.). Then you would nest another if statement like this …
(The code is now looking for the specific word “Sold” with a capital S and no spaces before or after any of the other letters.
$w.onReady(function () {
// Dataset Connected to Repeater
$w("#dataset1").onReady(() => {
$w("#repeater").forEachItem(($item, itemData, index) => {
//Repeated Text Element
if (itemData.isSold) {
let yesSold = itemData.isSOld;
if (yesSold === "Sold") {
$item("#text1").collapse();
}
}
});
});
});
If you need further clarification or private training, I am available for hire. Just reach out via email!
Nayeli
#codequeen
#totallycodable
nayeli@codequeen.us