On node view pages, the comments are shown below the node text, and this is sometimes very far down on the page (if the node body tekst is long). The pager below the comments (when there are more comments than allowed on one page) links to the top of the page, so the user has to scroll down past the node body on every page.
Unfortunately, theme('pager') doesn't support an #fragment argument.
This patch changes the $parameters and $attributes for the theme_pager_XXX functions into an $options argument that is passed on to l() ($parameters is $options['query'] and $attributes is $options['attributes']), i.e. a more general solution. This also allows passing other options to l(), e.g. $options['html'] (e.g. if the pager links contain an <img> tag).
Additionally I made it possible to specify a different path than the current path, e.g. if the pager is inserted as a block on some other page that the main page. I don't know if this is a valid use case, but it way easy to do, so I guess the flexiblility may come out handy to someone.
Comment | File | Size | Author |
---|---|---|---|
#6 | pager-options-2.patch | 13.15 KB | c960657 |
pager-options-1.patch | 13.09 KB | c960657 | |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedI tested this and it works as described. I haven't had a chance to fully review the code yet, but at first glance it looks pretty good to me and I think is a valuable improvement to the site visitor experience.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedActually, on the Find Content page, I get this notice:
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedSorry, it failed because I had done a git checkout and hadn't cleared the cache. This is why one shouldn't test patches after midnight ;)
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commented...or comment on issues after midnight. Changing back to needs review.
Comment #5
xjmTagging as novice for the task of rerolling the Drupal 8.x patch on account of #22336: Move all core Drupal files under a /core folder to improve usability and upgrades.
If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.
Comment #6
c960657 CreditAttribution: c960657 commentedComment #7
thedavidmeister CreditAttribution: thedavidmeister commentederror: patch failed: core/includes/common.inc:6623
error: core/includes/common.inc: patch does not apply
error: patch failed: core/includes/pager.inc:351
error: core/includes/pager.inc: patch does not apply
error: patch failed: core/modules/comment/comment.module:732
error: core/modules/comment/comment.module: patch does not apply
Comment #8
trisketonni CreditAttribution: trisketonni commented#6: pager-options-2.patch queued for re-testing.
Comment #16
almunningsI got around the problem like so, if anyone gets into the same situation as me:
In a .module file.
And when rendering the pager:
Comment #19
ilechcod CreditAttribution: ilechcod commentedThanks AL Munings, just used #16 - was a lifesaver. Very clever!!!
Comment #24
maxilein CreditAttribution: maxilein commentedThis should definetely be on core. It prevents many very useful ui functionality. Eg staying on the same tab after page reload ...
Comment #25
maxilein CreditAttribution: maxilein commentedI removed the: (comment pager should link to comment section of page) to make title more generic.
Comment #26
maxilein CreditAttribution: maxilein commentedPagers don't seem to support url fragment attributes.
https://somesite/somepage?someparam=somevalue#somefragment
If creating a url using tokens the fragment attributes get lost somewhere on the way to page reload.
A pager which can keep fragments until the next reload would enable a lot of useful features (like jumping back to a comment, reopening the last selected tab, ...)
Maybe this can help.
code sample of a custom module:
https://www.drupal.org/project/drupal/issues/1293912#comment-13219514
module for links with fragments
https://www.drupal.org/project/menu_link_fragment
older patch for D7:
https://www.drupal.org/project/drupal/issues/1216628
Comment #27
maxilein CreditAttribution: maxilein commented