Search saving
Posted by jamie on 25 Feb 2011 in Activity Log
Wrote a simple function to save the current search parameters so that the same results can be seen at a later date. This is the flow:
- User clicks on "Save Search" link at bottom of results
- Javascript function intercepts the link and sends an AJAX request to includes/helpers/save_search.php
- The save_search script loads the Search class
- The Search class in turn grabs the search params from the session, and saves a new record to the saved_searches table, and then returns the ID of the saved search record
- The save_search script returns a URL that can be used to access the saved search, which is just the search script (search.php) with a 'saved_search' GET parameter equal to the ID of the newly saved search
- The Javascript function informs the user of the successful save and provides them with the URL
- Success!