Hi I have a lightbox that i use to add comments to a post, and is opened by clicking on a button in the post's dynamic single item page. When i write the comment in the 'comments' database, i want to store the 'originating page' (meaning, the page from which i opened the lightbox) in the database field 'Originating page ID'.
As of now, the 'insert' code in my lightbox is as follow:
let toInsert = {
commenterId: $w('#dataset1').getCurrentItem()._id,
commenterImage: $w('#dataset1').getCurrentItem().profileImage,
commenterName: $w('#dataset1').getCurrentItem().fullName,
comment: $w('#comdatasetwrite').getCurrentItem().comment,
_createdDate: $w('#comdatasetwrite').getCurrentItem()._createdDate,
}
wixData.insert("comments", toInsert)
.then( (results) => {
let item = results;
console.log("OK")
Where the 2 datasets are the ones used to connect to the userProfile database (dataset1) and Comments database (comdatasetwrite).
I wonder if there is a way to add a row with something like this
originatingPostID: ...... //(something goes here - i bet it must connect to the userPosts dataset?),
Anyone can suggest a solution?
Thank you in advance
Hopefully I understand you correctly...
You can get the page you are on by using the Wix Location path() function.
If you're on a dynamic page, then you can get the dynamic page's prefix(), and then get the path().
You can then pass these details to your Lightbox.