Read more on same page, Next post/page via swipe, view for all pages

So my flow is this - A page with 10 posts,


  1. For the next 10 posts, I would like to have them below Read more or prioritiwise added below the above list. If I onclick, it does change page variable but changes the above posts too.

REST api with - /posts?per_page={per_page}

  1. On a single page post, I want to give a next article and preview article hover button. Right now I’m only trying a button. I somehow was able to pass the
    array of 10 article ID’s: How to get this array take repeated on each swipe / page with +1 and -1.
    pass a single id for next and previous post: It only works for a single post. If I go to next, the button diables.

Used: PICK_ITEM(PLUCK(data[“100posts”], “id”), INDEX_OF(PLUCK(data[“100posts”], “id”), INTEGER(params.currentID))+1)
REST API: only require id to get post details.

If I also try to get it done with 100 posts array then it screws the speed.

  1. Ability to choose from Either grid view or list view for pages.

@Harri_Sarsa Hey, anything on above…

Sorry for the delay!

You’d want to cache your already fetched posts in a page variable with the same schema, so after fetching your initial data, you could do it so that you append the second array to the first one. So let’s say you have a pageVars.allData array.

Then, after your Get record collection node, you use Set page variable, setting allData to

CONCAT(outputs["Get record collection"].records, pageVars.allData)

Now, we want to make sure we don’t have duplicates, so assuming your posts have unique id key, we write

UNIQUE_BY_KEY(CONCAT(outputs["Get record collection"].records, pageVars.allData), "id")

That way, when the logic flow fires and the outputs["Get record collection"].records has new records, they are added to the page variable array.

For the second part, you essentially want to have an array of IDs and be able to navigate from to the next/previous based on the current ID – so if I my IDs would be linear A, B, C, D etc, when I’m in B, prev ID is A and next one is C.

Since we are dealing with “sideways” navigation, you don’t really want to push a new page to the navigation stack. Instead, you’d want to update a pageVars.currentId that then fetches the new data when it changes by virtue of being bound to the right field under the data variable.

So, for simplicity’s sake, I’d set it up so that before navigating to details page, I set appVars.currentIds array with PLUCK(data["100posts"], "id"), and pass currentId as a parameter.

Then, the next button would set pageVars.currentId to formula

PICK_ITEM(appVars.currentIds, INDEX_OF(appVars.currentIds, pageVars.currentId) + 1)

And same for -1 to go back, and IS_EMPTY around the whole formula to set button visibility.

For the grid/list view, I’d just create two containers for list style and grid style, bound to the same data, and then toggle their Visible state via formulas.

1 Like

Just a quick question Harri, why do you use pageVars and not dataVars. I have noticed. Do you save dataVars as pageVars with a flow so it doesn’t post request api data everytime?

Also, How do I replicate the schema, it is quite big.

Data variable is just a page variable that gets its schema from the data resource it’s attached to and includes default logic to populate it (which can of course be deleted too), so either one can be used.

Copying schemas is manual work now, we’re working on a feature to make that easier sometime in the coming weeks.

1 Like