Collection page

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

  1. 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)

  2. 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.

Any thoughts ?

THanks !

Hi @Philibert :wave:

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 :slight_smile:

CleanShot 2023-10-20 at 11.46.01

1 Like

Thanks for the answer,

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 :wink: i removed the “-” in my DB anyway haha

Thanks !

Hi @Philibert :wave:

I don’t understand. If you are fetching a collection to get a single item, why do you need to update a variable?

Hi @Joyce !

Thanks for the answer.

Actually, I am not fetching a collection for a single Item.

  1. 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

  2. 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 …

Thanks !

Hi again @Joyce !

Do you have any recommendation regarding my previous question? I’m wondering if fetching a new item on page load could be more efficient …

Thanks

Have a good day

Clever! I hadn’t thought of doing that.

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.

Hey !
Thanks for the update :wink:

I might do that you’re right !

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

  1. a boolean that says to open modal or not
  2. 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 :wink:

Have a good day !

1 Like