hello,
i cant seem to get my code that is supposed to filter the items nested on the dynamic page where it should filter items matching the page name that is displayed in a text box.
i have not recieved any error, it is simply not showing anything but a blank screen on the preview
here is the code i am using:
import wixData from ‘wix-data’;
$w.onReady( function () {
dataset7filter();
});
function dataset7filter() {
$w(‘#dataset7’).setFilter(wixData.filter()
.eq(“pageId”,$w(‘#text58’).text))
}
p.s. i am not good eith code kindly help me out
If it is a members own page then you can filter the value for it in the dataset settings itself.
In the case of the “Owner” field, the “logged-in user” value is automatically filled in.
https://support.wix.com/en/article/about-filtering-and-sorting-database-content-displayed-in-page-elements#value
Also, read the same page page about filtering dynamic pages.
https://support.wix.com/en/article/about-filtering-and-sorting-database-content-displayed-in-page-elements#filtering-dynamic-pages
Otherwise, for setting the filter through code, have a look at the Wix Dataset and the setFilter function in the Wix API reference, which also contains many code examples that you can view and use.
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFilter
ok. thank you @sailorcihan . what i want to do is to filter data that belongs to a specific dynamic page according to the dynamic page that was opened. i want to do it by filtering the dataset by the page name after the page has loaded. The page is a public page and I have tried checking the code reference page for wix and i can’t seem to find what is wrong with my code. i have also checked answered questions on the forum but no luck.
I will really appreciate it if you can correct the code for me here. if you need more clarification please let me know
thank you very much.
i have solved it. thank you every one