Go To Topic - Like Phorum 3
Posted by Brian Moon
|
Go To Topic - Like Phorum 3 April 11, 2007 11:28PM |
Admin Registered: 25 years ago Posts: 4,506 |
I had half done this a while back for dealnews. I decided to make it work for everybody else. Phorum 3 had a link on the read page called Go To Topic. It would take you back to the message list positioned at the message you were reading. Also, when you replied to a post, you would be redirected back to that position in the list instead of the first page of messages. We didn't have float to top back then.
The core function has been tested on dealnews for a few years. However, some changes were made to make it generic. Please report any bugs.
Edited 3 time(s). Last edit at 04/12/2007 03:26PM by mmakaay.
The core function has been tested on dealnews for a few years. However, some changes were made to make it generic. Please report any bugs.
Instructions:
1. Edit your templates on read.php:
You will need to either insert a new link with the GO_TO_TOPIC_URL as the
href or change the existing Message List link to use this variable.
Example:
<a href="{GO_TO_TOPIC_URL}">Go To Topic</a>
2. Edit list.tpl and list_threads.tpl:
find: <a href="{ROWS->url}">{ROWS->subject}</a>
change to: <a name="msg-{ROWS->message_id}" href="{ROWS->url}">{ROWS->subject}</a>
Brian - Personal Blog
Edited 3 time(s). Last edit at 04/12/2007 03:26PM by mmakaay.
|
Re: Go To Topic - Like Phorum 3 April 12, 2007 05:05AM |
Admin Registered: 22 years ago Posts: 8,532 |
Thanks for posting. My users keep complaining about the missing go to topic feature after upgrading from Phorum 3, so we're on track for getting them off my back now ;-). I did find some issues in the code:
There's a "gotogopic" in the code.
Sounds cuter than "gototopic", but it makes the link ineffective.
The other thing that I see is probably coming from the fact that this was coded quite a while ago. IMO, the following code can be safely removed from the mod:
The last thing that I see is that a query is run for the "float_to_top" case, but the common hook actively ignores gototopic in case "float_to_top" is set. Allthough that is useful for gototopic calls that come after message posting (the new topic will be on the first list page, so no computations needed), it doesn't really help with go to topic links that are clicked when reading a message that is on a followup list page.
I'll see if I can come up with some fixes, since I've got some time at hand and defenitely want this feature implemented ;-)
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
There's a "gotogopic" in the code.
Sounds cuter than "gototopic", but it makes the link ineffective.
The other thing that I see is probably coming from the fact that this was coded quite a while ago. IMO, the following code can be safely removed from the mod:
if(!$PHORUM["threaded_list"]){
$sql="select count(*) as count from {$PHORUM["message_table"]} where sort=0
or (parent_id=0 and sort=1 and forum_id={$PHORUM['forum_id']})";
$res=mysql_query($sql, $conn);
echo mysql_error();
$count=mysql_result($res, 0, "count");
}
The sort=0 search would need parent_id=0 too, since the current Phorum 5.1 allows replying to announcements. But moreover, I think that this whole block could be stripped, because both announcements and stickies are not included in paging computations in 5.1. They are seen as a separate list of messages that has to be shown on the first list page.
The last thing that I see is that a query is run for the "float_to_top" case, but the common hook actively ignores gototopic in case "float_to_top" is set. Allthough that is useful for gototopic calls that come after message posting (the new topic will be on the first list page, so no computations needed), it doesn't really help with go to topic links that are clicked when reading a message that is on a followup list page.
I'll see if I can come up with some fixes, since I've got some time at hand and defenitely want this feature implemented ;-)
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: Go To Topic - Like Phorum 3 April 12, 2007 07:03AM |
Admin Registered: 22 years ago Posts: 8,532 |
Another thing is the use of ceil(<offset>/<page length>) as the algorithm for determining the page to show. I think it should be floor(<offset>/<page length>)+1 instead.
In the graph below, I show why I think this. The graph asumes a list length of 5. The offset is the number of messages that come before the selected one. So for example message 4 will result in ceil(3/5) or floor(3/5) and message 9 will result in ceil(8/5) or floor(8/5).
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
In the graph below, I show why I think this. The graph asumes a list length of 5. The offset is the number of messages that come before the selected one. So for example message 4 will result in ceil(3/5) or floor(3/5) and message 9 will result in ceil(8/5) or floor(8/5).
ceil(offset/5) 0 1 1 1 1 1 2 2 2 2 2 3 ...
--------------------------------------------------------------
1 2 3 4 5 | 6 7 8 9 10 | 11 12 ...
--------------------------------------------------------------
floor(offset/5)+1 1 1 1 1 1 2 2 2 2 2 3 3 ...
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: Go To Topic - Like Phorum 3 April 12, 2007 09:25AM |
Admin Registered: 22 years ago Posts: 8,532 |
I fixed the problems that I found and changed the module to have language and multiple database backend support. The updated module can be found in the first message of this thread.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Sorry, only registered users may post in this forum.