jessevl Posted January 12, 2015 Share Posted January 12, 2015 Hi, I'm working on a Processwire powered directory-like website where users can register on a front-end and post new pages to a directory. Users can also list certain preferences (linked as pagefields) in their profile and the website then shows only the pages in the directory that fit these same preferences. So far so good, I'm pretty sure that I set that up the way it's supposed to (or at least a generally acceptable solution). However, I also want users who aren't logged in to be able to filter these pages in the directory. While this in itself is fairly simple I also want to allow the viewer to add and delete some of these filters and show the viewer the currently selected filters on the frontend, so I should store the currently selected filters somewhere. The way I do this now is by having several select elements post the requested filters to the template page and then assigning these to a new user object and simply not save the user object, and consequently return all filters on the non-saved user object to the form. When a viewer selects or deselects certain filters the entire list of filters is posted again and added to a new user object, which then again returns to the form and isn't saved. This works really well, however, I'm wondering if it is acceptable practice to create user objects and not save them just to temporarily store some information? Do non saved objects still leave some traces anywhere in the DB maybe? Thanks! Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 13, 2015 Share Posted January 13, 2015 Unsaved pages, as users are also pages, are just an instance of a standard php object. There's no database involved as long as you don't use save(). That's also the reason, why you can't upload files to pages as long as they aren't saved and thus don't exist from a database standpoint. 4 Link to comment Share on other sites More sharing options...
jessevl Posted January 13, 2015 Author Share Posted January 13, 2015 Makes sense, just wanted to be sure. Thanks for the explanation! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now