Page Memory

Error message

  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of /var/www/pied-piper.ermarian.net/includes/menu.inc).
Isn't that annoying? You're browsing through a part deep in the middle of the forum pages, read a topic, then click the forum link in the breadcrumb trail to get back to the forum...

And land on page 1, having to go back to the page you were on with several clicks.

On a forum, this is common practice, and the trick is to use the back button on your browser to get back to the next thread. And you're probably not reading that far back - why didn't the admin yet prune the old topics, anyway?

But here we are on an archive, its very purpose being to read very far back. So I just added a little something that will make navigation easier.

Introducing Forum Page Memory

The whole thing works with sessions. When you look at a page in the forum, PPP will save the page number in a session variable - and the sorting order too, if it's not the standard one.

Then, when you read a thread, PPP will check if the session variable is set. If it is, an extra link will appear in the breadcrumb trail. This link is called something like "Page x", and will take you right back to the page you were on - with the proper sorting order!

This even works when browsing multiple forums - each forum has its own page memory.

The only thing that doesn't quite work is browsing several different pages on the same forum. The memory gets overwritten, and the breadcrumb link will point to the wrong page. This could be fixed with referrers.

The reason why I couldn't use referrers in the first place, of course, is that the feature would stop working when you read other pages of the same topic.

Perhaps a hybrid of referrers and session...? Looking at the referrer first and updating page memory if we came from a forum link, but using the session variable if we didn't...

But this would still cause problems if we had multiple topics open at the same time. Unless the page memory were individualized for every single topic....

That's it!

Hierarchical page memory!

Whenever we open a topic page:

1. Referrer is checked. If we came from a forum page, the topic page memory is updated with the data from the referrer, and nothing else happens.

2. If not, topic page memory is checked. The memory is not changed in any way.

3. If topic page memory does not exist either, check forum page memory. If it is set, topic page memory is updated from forum page memory.

4. If forum page memory is also not set, we don't need to show any page - the topic was obviously deep-linked from somewhere, and needs no forum context.

----

Whenever we open a forum page:

1. Forum page memory for this forum is overwritten with the current page and sorting order.

----

This ensures that you can be looking at three different pages of the same forum in different tabs. When you click a topic link in any of them, they will link back to the page they were visited from. If the topics has several pages, you can read them simultaneously - each topic will continue to link to the page it was visited from.

Sometimes I feel like a genius. It's quite rare though, and usually wrong.

Addendum: Implemented. The page memory now works like a charm.