Hi I need help in filtering elements to show on a page depending on which profile is logged in.
I need it to collapse columnstrip1 and expand columnstrip2
THE PROBLEM
it deosnt seem to filter rigth
$w.onReady(function () { pagepermitjeffreysA(); pagepermithazelsA(); }); function pagepermitmarygraceA() { let url = wixLocation.url; if (url === "https://www.getservxperience.com/****************") { wixData.query('profile2022') .eq('companyName', 'Jeffreys') .find() .then((res)=>{ if (res.length > 0) { $w('#columnStrip1').expand() $w('#columnStrip2').collapse() } else { $w('#columnStrip1').collapse() $w('#columnStrip2').expand() } }) } } function pagepermitdennysA() { let url = wixLocation.url; if (url === "https://www.getservxperience.com/********************************") { wixData.query('profile2022') .eq('companyName', 'Hazels') .find() .then((res)=>{ if (res.length > 0) { $w('#columnStrip1').expand() $w('#columnStrip2').collapse() }else { $w('#columnStrip1').collapse() $w('#columnStrip2').expand() } }) } }
I'm not sure if I'm understanding your code, but from what I'm seeing your 2 functions are called back to back and are conflicting with each other
For example
if function 1 evaluates to true ( expand strip 1)
and if 1 is true, I am assuming that means function 2 will be false, but in the else you have if function 2 is false (collapse strip 1)
So, it looks like it will never work.
I would combine these functions and only call the query once based on which URL returns. Something similar to this pseudocode:
$w.onReady(function(){ //get urls here let id = "" if (url === the hazel url){ id = "hazel" queryData(id) }else if(url ==="jeffrey url"){ id = "jeffrey" queryData(id) } }); //in your query data function pass the id to the filter and run the query once