I am trying to connect a news list to a database. how can I do that using developer tools. It is working if I add any style from User Input tab but it is not connecting any other option under List tab.
Hi Shruti,
can you please add a bit more information?
maybe a screenshot?
would help a lot to guide you through it.
thanks.
When I select any of this list option, I don’t find any way to connect with database to make it dynamic. I also want to set a limit for dynamic page like top 10 items only not all.
Hi Shruti,
the lists feature is not part of the wix-code offering. you can actually think of wix-code as a replacement for the lists feature (and much more).
to create a dynamic list of things use of of the components that can show multiple items at once:
- a table component
- a gallery component
- [in the future] a repeater component
design it to look like you want it to, and then connect it to data from your collection.
in order to set the limit of number of items to fetch, you can use a backend query hook .
but first let me explain how datasets work with wix-data and the hook system.
when a dataset fetched data from the underlying collection, it creates and runs a wix-data query .
this query is executed on the server side.
user code (the code you write) can intervene in that query execution in certain points.
in our case, the point to intervene is in the “before query” hook.
this hook allows your code to modify the query before it is executed.
so what I would do is this:
-
add a “beforeQuery” hook to the relevant collection
see here:Hooks - Velo API Reference - Wix.com -
modify the query so that it includes a “limit” of X items
see here: https://www.wix.com/code/reference/wix-data.WixDataQuery.html#limit -
return the query and let it execute
that’s it.
hope it helps!