Hey !
I am now building collection pages from a dynamic import using Supabase (Maybe I’ll do static later - I saw it is not built-in with supabase)
I came accross different ressources and tips about this subject like passing a variable to store …
I wanted to try different approachs
On click, send the UID in the parameter of the template page and on page load, load the collection from supabase with a filter using the UUID (problem : slow and costs a lot in API)
On click, send the UID in the parameter of the template page and on the template load, update a variable that is a tab containing the collection Item with the UUID from the parameters
Question : what do you think about option 2 ? It seems good to me but might be a bad practice … Also I saw some bugs reports when using the UUID from supabase in the url parameters, when publishing the project.
Do you want users to be able to access the item information when you share the link to the item directly (without going through the page with the list of items)?
If yes, then option 2 is not viable because the variable would be empty.
Regarding the bug with UUIDs, this was corrected a couple of weeks ago so you should be fine
I did considered this issue and that’s also why i went for (2).
Since I am changing this variable on page load (on the page load of the “template collection Item”) => on page load the variable takes the Item which UUID is the parameter UUID that is in the link
Therefore if i share the link it should work ? Is there a problem to load the collection ?
Great for UUIDs i removed the “-” in my DB anyway haha
Actually, I am not fetching a collection for a single Item.
I fetch it only once, then when the user clicks on the item, the workflow is : go to page template and the UUID is given in the template’s (collection page) URL
On the template page load, I store in a variable type object the Item that has the uuid specified in the parameter URL (here is the formula : filterByKey(collection,“UUID”,context.pageParameters[‘id’])[0]
This way I do not have to fetch the collection with one item.
(I still don’t know if its the most efficient practice but it works so far) - maybe if the link is shared the total collection is not fetched ? maybe i should in this case fetch a collection to get the single item …
Mmm yes, definitely worth testing. You could have a branch in your workflow where if the collection is empty, you fetch the collection before setting the variable.
Also, I might change and show the item page in a popup (but there’s an other popup in the item page so I’ll see) → this would allow showing the item and hiding it without having to reload the home page (that is a bit heavy)
For the sharing part, I immagine giving parameters direcly in the home page with
a boolean that says to open modal or not
The UUID of the selected item
This way on share, the popup is opened with the right item in it
IDK if its good practice but seems like a good trick