I’m not familiar with repeaters and the codes to interact with them, but I imagine it’s pretty much the same thing as what I did, you need to extract the ID of the feedback owner, then use that to get their names and push that to a text box in your repeater.
So most of the code that I used can work for you, it only needs to point to your repeater text boxes rather than a dynamic page text box.
Ok, so when you use the code to extract the ‘_owner’ database entry, you then just need to query the Members database to find the ‘nickname’ (ie. first and last name together) of the user with this ID.
For this, you can use my backend function as a first step:
BACKEND CODE - saved as module secureSlug.jsw
import wixData from 'wix-data';
// This makes sure the function gets the variable from the frontend as 'ownerID'
export function getSlug(ownerID) {
// This bypasses the permissions check so the query can run for any user, not just the Member who owns the asset
let options = {
"suppressAuth": true
}
// This runs the query with the above option in place and finds the Member who's ID matches the _owner ID of the Item displayed on the dynamic page
return wixData.query('Members/PrivateMembersData')
.eq('_id', ownerID)
.find(options)
}
Then you need to take the results of that query in the frontend and extract the ‘Nickname’ that corresponds to that ID:
FRONTEND CODE
Make sure you add: import {getSlug} from ‘Backend/secureSlug.jsw’
to the top of your Frontend code window to import the backend function, so you can use it in the frontend.
// This passes the ownerID variable to the backend function above
getSlug(ownerID)
// Note that the .find instruction is in the backend (where permissions are bypassed through code above) but the .then instruction is here in the frontend, so that I can access the elements of the returned item and define fields to use on the page
.then((results) => {
let item = results.items[0];
let nickname = item.nickname;
// This inserts the dynamic item owner's nickname (from the Members/PrivateMembersData collection) into a text box on the dynamic page to show them as the author of the dynamic item displayed
$w('#Author').text = nickname;
})
From what I see in your code, you’re trying to extract an Owner ID from your #UsersPostsBooks dataset (which I assume is a dynamic dataset?) and you then want to filter your other #dataset5 to only show assets owned by this Owner.
I think the issue is with your filtering on your #dataset5. I believe that you’re trying to match an asset ID (_id) with the Owner ID (_owner), which may be why you’re facing a problem. If you switch it to this, it might work:
It might also be worth checking that you have the Hook in place on the collection that your #UsersPostsBooks dataset links to (see my code above) so that the authorID variable gets generated. Otherwise, it will return either an error or an empty field and that will also affect your filtering on your #dataset5.
Hi,
I followed all the the steps mentioned above & its work fine but i’m getting error in my console:
" Cannot find module ‘Backend/secureSlug.jsw’ in ‘public/pages/mplin.js’ "
The error message is basically telling you that the program can’t find the backend module in the specified place.
I think that might be because you didn’t save the Backend module under the same name as I did, or you saved it in a different place?
If everything else works fine, though, I’m not sure why this error appears since the whole process only works if you have that module in your Backend code.
Check that the results returned are indeed correct and that the IDs of your assets and owners match. That should tell you if the module is being bypassed or if it is just saved elsewhere or under a different name.
hey i got the same problem as claudio ( btw idk why but i can’t acces hooks through the content manager so i have to write the code directly in the data.js file i don’t know if that affects the proccess ) merci ^^