Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently the navigation links appear in the links section of the node page (with comment links,...).
For easier theming, it would be nice to have a block available too.
Comment | File | Size | Author |
---|---|---|---|
#1 | block-links-1979500-1.patch | 2.42 KB | lukio |
Comments
Comment #1
lukio CreditAttribution: lukio commentedThe attached patch provides a block which renders prev and next links.
The code that builds the links was moved from hook_node_view to its own function.
I patched the views_navigation.module first with the #1990384: Files should be formatted with \n as the line ending (Unix line endings), not \r\n (Windows line endings). issue
Comment #2
GaëlGGreat, thank you.
I added DRUPAL_CACHE_PER_PAGE in the hook_block_info: the block content will change according to the GET parameters. This is a common omission which can give cached sites a weird behavior.
I also rewrote a bit the code in hook_block_view: no need to return an array with empty values: the default NULL return value for functions should be correctly handled by Drupal. And I moved the new helper function views_navigation_get_links() to the .inc file to keep the .module clear (only hooks).
Anyway, thank you again and long life to cooperatives ;)
Committed to dev.