You will need to use global variables to store and access data across pages. You don’t mention repeaters, but this post is tagged with “repeater-widget”. Sharing data between repeaters on different pages can be more complex, because you need to build or update the repeater automatically on page load. The easiest way to do this is to have the same basic repeaters on both pages. They don’t have to be identical in terms of layout or repeater widgets, but should have the same list of items (number of rows) and a common way to refer to each item in both repeaters, like an index, product number, or unique name.
For example, let’s say on Page 1 you have a carousel of 5 items, represented as a horizontal repeater of 5 rows. When a user likes an item, a corresponding global variable can be set. For the sake of simplicity, you could have 5 global variables, Fav1, Fav2, Fav3, Fav4, Fav5. When the user clicks the Like button in row 2, it can set Fav2 to “true”.
On Page 2 let’s say you want to show a vertical list of all liked items from the carousel on Page 1.
You can have a repeater on Page 2 with the same 5 rows (but styled to show the list vertically, maybe less or more info per item, etc. but the same basic items in the same order.) Then, you can have a series of conditional cases that tests the value of Fav1, Fav2, etc. and shows the corresponding row if the value is “true” by applying a filter. Do this in the Page Loaded event to make it automatic–something like,
Page Loaded
Case 1
If value of Fav1 equals “true”
Add Filter
MyRepeater add [[Item.index == 1]]
Case 2
If value of Fav2 equals “true”
Add Filter
MyRepeater add [[Item.index == 2]]
… etc. for all rows
I’m not sure what this means… If you delete a list item, that means it gets removed, which typically changes the layout of the list, especially in a repeater. So, could you please clarify what you mean by “delete items” and maybe which list… the original list of items that can be liked, or the subsequent list of liked items? …Or maybe “deleting” really means just clicking the Like button again to deselect it? Either way, how would the layout not get impacted? Maybe you could share some examples or sketches of layouts for various states?
If you could reply here and upload a sample .rp file it will be much easier for forum users to provide solutions tailored for your needs.
Here is a demo I made for you, based off one I made a few years ago.
repeater favorites across pages.rp (158.5 KB)
-
On Page 1, there is a repeater with a few items. Clicking an item “likes” it, showing a “favorite heart” icon. Clicking again “unlikes” it. This prototype uses one global variable, VarFavorites, to store which items are liked. As each item is liked (selected) it adds itself to VarFavorites, thus creating an array (a “list” as the variable value.) When unselected it removes its value from VarFavorites. (This is done with built-in string functions that you can inspect in the interaction code.) This is a more extensible way to represent liked items; you can add or remove items from the repeater and the code will still work (just be sure to add the same rows to the repeater on Page 2.)
-
On Page 2, there is a corresponding repeater, prebuilt with the same items as the repeater on Page 1. It has a Loaded event (triggered after all its items are loaded) that adds a filter to itself, hiding all the rows by default.)
- The Page Loaded event copies the value of VarFavorites to OnLoadVariable (the built-in global variable). Then it triggers a recursive subroutine to filter the repeater based on which items have been liked–the values in OnLoadVariable. The subroutine is represented as a dynamic panel, “ShowFavs”, with two empty states. Each time ShowFavs changes state it looks at the first value in OnLoadVariable, and updates the corresponding repeater row, setting the “Fav” column cell to “true”, then pops that value off of OnLoadVariable, then changes its state to Next, wrap (making it a recursive function/subroutine.) In this way, it walks through each liked item until there are no more items to process–thus the value of OnLoadVariable is blank. When this happens, it adds a filter to the repeater with the rule,
[[Item.Fav == 'true']] remove other filterswhich results in showing only the liked/favorite items. Note that the original set of liked items is still stored in VarFavorites (which comes in handy if user needs to navigate back to Page 1.) - There are a set of test buttons which can help demonstrate how things work. They are for learning purposes only and can be deleted.
- The Page Loaded event copies the value of VarFavorites to OnLoadVariable (the built-in global variable). Then it triggers a recursive subroutine to filter the repeater based on which items have been liked–the values in OnLoadVariable. The subroutine is represented as a dynamic panel, “ShowFavs”, with two empty states. Each time ShowFavs changes state it looks at the first value in OnLoadVariable, and updates the corresponding repeater row, setting the “Fav” column cell to “true”, then pops that value off of OnLoadVariable, then changes its state to Next, wrap (making it a recursive function/subroutine.) In this way, it walks through each liked item until there are no more items to process–thus the value of OnLoadVariable is blank. When this happens, it adds a filter to the repeater with the rule,
-
Back on Page 1, the liked items are restored in the repeater (if a user navigates back to this page from Page 2 or elsewhere) via the Page Loaded event.
- OnLoadVariable is set to the value of VarFavorites.
- VarFavorites is then set to blank. It will be rebuilt as items are set to “Like”.
- Because this repeater is structured a little different from the Page 2 repeater, it doesn’t need the recursive subroutine. Rather, a “listener event” is set up in the “rowGroup” widget group in the repeater. Its Moved event “listens” to OnLoadVariable, and if it “hears” its number, it sets its selection state to “true”, marking it as liked (just the same as if a user clicked it …which they actually already did the last time they were on Page 1).
That’s pretty much how this works. Reply with any further questions about details, or if anything should behave differently and you can’t figure out how to do it.
If your Liked/Saved list on Page 2 is not a repeater, then you can create a set of items to match those on Page 1, hide them all by default, then use Page Loaded with conditional cases to show certain items, based on global variable values.
If your lists are dynamic repeaters, meaning the user (or your interaction code) needs to edit, add, or remove rows on Page 1, you can use similar logic to add rows to the repeater on Page 2. If it is possible to add new items (rows) or edit data, e.g., maybe a name or comment field, and you want to transfer this to the list on Page 2, then you’ll need to store all that data in the global variable(s) on Page 1, then add rows to a blank repeater on Page 2 using the data in the global variables.
Here is a post with examples of how to do this more advanced and more extensible repeater copying across pages: