跟踪多个页面引用者级别

The scenario (all happening within the administration area/backend):

  1. From the listing page, the user clicks a link to view an article (on the backend).
  2. From the article view page, the user clicks a link to edit that article.
  3. In the article edit page, form is submitted to the current uri.
  4. If validation succeeds or user cancels, user is redirected to the article view page.
  5. From the article view page, the user click a 'back' link to return to the listing page.

List <--> View <--> Edit

Right now, I'm only able to track referring url from a previous page. In the edit form, I'm using a hidden field to maintain referral to the view page, lest it be changed during failed form POST submission to itself and user remains in the edit page.

Problem is that when the user returns to the view page from edit, the 'back' link to the listing page is now linked to the edit page.

FYI,

  • The listing page url is dynamic as the user should return to the listing on the same page and sort order (stored in query strings); therefore a fixed url is out of the question.
  • In the past, I've tried using sessions (e.g. SESSION['view_to_list_ref'] SESSION['edit_to_view_ref']), but it messed up with multiple tabs.
  • I could transition between view/edit via ajax, but I'm hoping to keep the app simple and ajaxless at this point of time.
  • I'm using PHP + Kohana 3.2 Framework

The only solution I can think of is to have the list page url encoded and appended to the 'view article' link via query string. This way, the location of the listing page is preserved even while in the edit page; as the referring url back to view page would also contain the listing page url in the query string. However I don't really like the idea of 'dirtying' the url with long parameter values (encoded or not).

I'm really hoping there is a more elegant solution to this problem of generally tracking multiple levels of page referrals; not just specifically to solving the scenario I've mentioned.

EDIT: Oh and the solution should be able to support multiple tabs performing the same scenario.

You could track the pages by using a unique identifying code in a PHP session, a temporary variable, and using a temporary database table that tracks page loads by these temporary values.

The database structure might be:

+-------------+-------------------+---------------------+
|  Unique ID  |    Page Referral  |   Time of page load |
+-------------+-------------------+---------------------+

Tracking time of page load would allow you to selectively wipe loads older than X minutes, and keep the table relatively small.

Anyway, this would allow you to keep as many levels as you'd like, and if you wanted to add an auto incrementing counter field, or your own counter field, you could even keep a simple to use number system that tracks page loads, though I believe the time of page load would suffice for that scenario.