Logic to find next item

There is a Data type (blog), with list of posts.

Each post has Title and Number (number helps us sort the posts continously)

When user is at one post, and there are buttons to go “up” or “down”, to find the next post based on the current post number and first post with the number either higher (down) or lower (up).


If you sort your blogs using the number then you can use Show next or Show previous to navigate up and down your RG.


1 Like

Yes, but this will show next/previous from the database, where there are not ordered as on the front end. On the front end we use the sort “number” field to sort items by the number in the field. :smiley: Or can we use somhow the show next/previous while refering to this dynamic field?

Hey @another , use #indexi.e current cell index + 1, -1 on button clicks

1 Like

When fetching data from the db, you can sort hence you’ll receive sorted list. Hence you can comfortably use show next and previous.

1 Like

@alan.thomas111997: Using index also comes down to previous and next value in the database, rather refering the the Number field in the database, or can we refer the index to the custom field in the database?

@koechamos51: Yes, it seems possible with Search for content:sort by Number:First item (and then work with descending yes/no, which doesn’t work, or what you mean here, how we can get the next/previous item with :sort based on the Number field?

@another sort your repeating group with number field (ascending) and then use index to navigate to next and previous.

Yes, good point, however, we are here in the content, rather on a repeating group level. Blog post (content) has buttons up/down, to go to next/previous post.

Posts are sorted with dynamic Number input in the Data Type, rather by created date.

If this case still possible?

If on the content. You can use number to search the next or previous ±1 and use display data in the group reference being the current page data

1 Like

You mean like this?


Here we don’t have current content value, so the Search don’t know what is the current sort number, to find the next/previous number. How we can include the Parent content sort number value?

Yes, with sort number being parent group content sort +-1.Since you just fetching one value no need to sort again

1 Like

Yes, but not that easy :smiley: If you check the photo in the begining of the post, sort numbers are not 1, 2, 3, 4, 5, 6, etc., rather 10, 20, 30, 40, etc., and sometimes would be to go between 80 to 200, because at 80 one group of contents are finishes, and next group starts at 200. How we can make this happen for user to be able to go to the next content with higher valua or lesser, depending on the current content? :slight_smile:

Previous item is any item which the sort no is less than current page sort number, next content will be any content whose sort number is greater than current sort number. You’ll need to sort descending and ascending respectively for this to work.

1 Like

Ok, that is good news. Finally! :slight_smile: Can you write here how the Search condition will look like? Thanks!

Next Button,

1 Like

Yes, it works :smiley: Thanks a lot @koechamos51! Great logic :raised_hands:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.