Forum: Pager links in Forum topics list

MrEricSir - January 18, 2006 - 00:48
Project:Drupal
Version:7.x-dev
Component:forum.module
Category:feature request
Priority:normal
Assigned:Gurpartap Singh
Status:needs work
Description

This adds page links to the list of forum topics, much like phpBB and other popular software.

Example:

Before: "This thread rules!!!!"
After: "This thread rules!!!! [ 1, 2, 3, 4]"

Where 1, 2, 3, 4 are links to those pages in the topic.

Benefits:

  • Users of popular forums have less clicking to do.
  • Saves a few page loads, especially if tracker disabled.

Drawbacks:

  • Had to impliment my own pager for this.
  • Should be tested further.

Note: this version will NOT WORK with 4.6.

AttachmentSize
dif.txt2.04 KB

#1

MrEricSir - January 18, 2006 - 00:51
Title:Topic pagination in forum view (with patch!)» working patch

Oops!

That's an anti-patch... or something.

The corrected version is attached to THIS post.

AttachmentSize
dif_0.txt 2.04 KB

#2

MrEricSir - January 18, 2006 - 01:03
Title:working patch» Forum.module topic list pagination

For a 4.6 version of this patch, see this thread:

http://drupal.org/node/44876

#3

MrEricSir - January 23, 2006 - 18:39
Title:Forum.module topic list pagination» Patch: Forum.module - page links in topic list

New in this version of patch:

  • Optimization: Never displays more than four links
  • Style: Page flicker looks more like other forum software

Has anyone else tested this patch?

AttachmentSize
forumPagination.patch 3.27 KB

#4

MrEricSir - January 24, 2006 - 01:44
Status:needs review» reviewed & tested by the community

This version of the patch should work easily with the forum.module cvs. It's been cleaned up a little and afaik complies fully with the Drupal coding standards.

I guess the code could be made cleaner, but I've tested it thoroughly as-is and don't want to upset the delicate balance of the force. I doubt it could be made significantly more efficient anyway.

AttachmentSize
forumPagination_0.patch 2.96 KB

#5

chx - January 24, 2006 - 02:11
Status:reviewed & tested by the community» needs work

thanks for the hard work, but you should let others review your patch before setting ready to commit.

Also... Drupal already have a pager system. I doubt this patch will accepted as it's essentially code doubling.

#6

MrEricSir - January 25, 2006 - 09:43

You're probably right that it needs review.

But as far as I can tell there's no way to create a pager using existing functions without calling pager_query().

Maybe I'm wrong, but calling pager_query() for each topic seems excessively database intensive. That's why I felt the need for a custom pager.

#7

chx - January 25, 2006 - 09:47

You are right in that currently there is other way but then you should extend pager.inc so that it can? You only need a function which would initialize some vars.

#8

MrEricSir - January 26, 2006 - 02:40

Cool, I'll look into it.

Do you have any recomendations on how this should be done?

#9

MrEricSir - January 27, 2006 - 05:06

Okay, I looked into it myself. Sadly this cannot be done using the existing theme_pager_link(). I'll have to modify it to accept a new parameter.

The offending line is this one:
return l($text, $_GET['q'], array(), count($query) ? implode('&', $query) : NULL);

I could just set $_GET['q'] = "node/$topic->nid"; but that would break other pagers, and it's a lousy hack in the first place.

#10

MrEricSir - January 27, 2006 - 05:30

Wait... so if I change a theme fuction, wouldn't that break all existing themes?

Maybe my dirty hack was a better idea...

#11

MrEricSir - January 27, 2006 - 22:13
Title:Patch: Forum.module - page links in topic list» Forum.module: topic page links

I discovered a workaround, and after some testing got it running. I'm not sure how "legal" something like this is:
$_GET['q'] = "node/$topic->nid";

This is due to the following line in theme_pager_link():
return l($text, $_GET['q'], $attributes, count($query) ? implode('&', $query) : NULL);

So to change the link, I either have to set $_GET['q'] or modify ALL the pager theme functions! Another possibility is to add some kind of global variable containing the link that only theme_pager_link() would use.

Any comments on the perferred way to implement this functionality?

AttachmentSize
forumPagination_1.patch 2.22 KB

#12

chx - January 27, 2006 - 22:21

looks good to my eyes -- but Dries may think otherwise. However, I would $on_page = $_GET['q']; // store current url just above the $_GET['q'] statement.

#13

Jaza - January 18, 2007 - 05:48
Version:x.y.z» 6.x-dev

Moving to 6.x-dev queue.

#14

catch - October 24, 2007 - 13:39
Version:6.x-dev» 7.x-dev

We've done some template hacks to get this into forum listings (and hacked views.module slightly to get the same on the tracker). Will try to post up some of that code later if it takes a different approach. For drupal 7 though.

#15

Gurpartap Singh - May 18, 2008 - 20:11
Title:Forum.module: topic page links» Forum: Pager links in Forum topics list
Assigned to:Anonymous» Gurpartap Singh
Status:needs work» needs review

Screenshot is attached to this comment. Ignore the date created thingy.. that's going into another issue.

If this gets good reviews and code improvement suggestions, I'll be taking up with more forum UI issues!!

AttachmentSize
Drupal 7 - Forum Mockup.png 64.7 KB
d7-f_forum_topic_pager.patch 4.78 KB

#16

Gurpartap Singh - May 18, 2008 - 20:15

This time without tabs.

AttachmentSize
d7-f_forum_topic_pager.patch 4.81 KB

#17

dmitrig01 - May 18, 2008 - 20:22

"+  //print '<pre>'; print_r($items); print '</pre>';"

Uh

#18

Gurpartap Singh - May 18, 2008 - 21:42

I'm wondering why drupal_add_css() for forum.css in forum_init() is not adding forum.css........... In the patch I re call drupal_add_css for that. Is that a bug or I'm missing something?

AttachmentSize
d7-f_forum_topic_pager.patch 5.07 KB

#19

Gurpartap Singh - May 21, 2008 - 16:11

bump

#20

Gurpartap Singh - July 6, 2008 - 13:46

Hope this still applies..

#21

Michelle - July 6, 2008 - 13:53

Huh... Never knew this issue was here. I do this in advforum. Will take a look at this when I have a chance to see which method is better :)

Michelle

#22

Gurpartap Singh - July 6, 2008 - 15:09

Nor did I ever know it was there(in advanced forums). Hehehehe.

#23

-Shaman- - September 15, 2008 - 18:24

I've noticed bug in this patch, after nearly year of using, because before I haven't got such a long topics.

When navigate to a second page of topic listings, all thread pagers also showing 2 page active, it's true for next pages as well of course.

Screenshot as an attachment.

AttachmentSize
pager.png 48.6 KB

#24

catch - September 15, 2008 - 20:27
Status:needs review» needs work

Looks like it needs work.

#25

ton_cut345 - December 4, 2008 - 00:16
Version:7.x-dev» 6.x-dev

how about for drupal 6???

#26

Michelle - December 4, 2008 - 00:33
Version:6.x-dev» 7.x-dev

D6 is feature frozen and this isn't a bug so it won't get backported.

Michelle

#27

mitchell - April 30, 2009 - 03:59
Status:needs work» duplicate

Duplicate of #33809: Hard coded pager limits, and more so #286665: Moving Views into Drupal Core,.

I started #449236: Move Forum to CCK + Views to coordinate Forum development.

#28

Gurpartap Singh - April 30, 2009 - 08:32
Status:duplicate» needs work

Views isn't in core *yet*.

 
 

Drupal is a registered trademark of Dries Buytaert.