Entity Pager

Provides next and previous navigation links on entity pages using Views as the data source.

entity_pager
2,174 sites
33
drupal.org

Install

Drupal 10, 9 v8.x-1.0
composer require 'drupal/entity_pager:8.x-1.0'

Overview

Entity Pager is a Drupal module that provides previous and next navigation on entity pages, allowing users to browse through a series of entities without returning to a listing page. The module leverages Views to define the set of entities to navigate through, making it highly flexible and customizable.

The module works by creating a Views block with the Entity Pager style plugin. When placed on an entity page, it automatically determines the current position in the view's result set and displays navigation links to the previous and next entities. It also supports an optional "All" link that can point back to a listing page or any other URL.

Entity Pager supports token replacement in link text and URLs, enabling dynamic content based on the current entity. It can also work with Views relationships to navigate through related entities, such as navigating through all products of a specific brand.

Features

  • Provides previous/next navigation links on any entity page (nodes, users, taxonomy terms, etc.)
  • Uses Views as the data source, allowing full control over entity ordering and filtering
  • Supports customizable link text with HTML and token replacement
  • Configurable "All" link to return to listing pages or related entity pages
  • Supports Views relationships to navigate through related entities
  • Circular paging option to wrap from last entity to first and vice versa
  • Optional display of position counter (e.g., "2 of 5")
  • Option to show or hide disabled navigation links on first/last entity
  • Includes a demonstration view and block for quick setup
  • Supports multilingual sites with proper language handling

Use Cases

Blog post navigation

Add previous/next links to blog posts so readers can easily navigate through articles in chronological order. Create a View of all published Article nodes sorted by date, set the style to Entity Pager, and place the block on article node pages.

Product catalog browsing

Allow customers to browse through products within a category. Create a View with a contextual filter for the product category, use the Entity Pager style, and users can navigate through all products in the current category.

Portfolio navigation

Enable visitors to browse through portfolio items or case studies. The 'All' link can be configured to return to the portfolio landing page using the token [site:url]/portfolio.

Related entity navigation with Entity Reference

Navigate through products belonging to a specific brand. Using Views relationships and the Entity Reference token in the 'All' link (e.g., [node:field_brand]), users see 'Previous - Brand Name - Next' where clicking the brand name returns them to the brand page.

Photo gallery browsing

Allow users to view photos one at a time with previous/next navigation. The display count feature shows '3 of 25' so users know their position in the gallery.

Documentation sequential reading

Guide users through documentation pages in order. Circular paging can be enabled to loop back to the first page after the last, creating a continuous reading experience.

Tips

  • Use the demonstration view 'Entity Pager Example' as a starting point - enable it and examine its configuration to understand how the module works
  • Set 'Items per page' to 0 (unlimited) in the view's pager settings to include all entities in the navigation
  • For better performance with large result sets, consider adding appropriate caching to your view
  • Use HTML in link labels for custom styling, e.g., '<span class="icon-prev"></span> Previous'
  • When using entity reference tokens for the 'All' link URL, use the same token for the link text to automatically display the referenced entity's title
  • The view must be a block display - page displays are not typically used since the entity pager is meant to appear on entity pages

Technical Details

Troubleshooting 4
The entity pager block shows nothing on the entity page

Ensure the entity's ID field (e.g., nid for nodes) is included in the View's fields. The view must return the entity IDs to determine the current position. Also verify the current entity matches the base entity type of the view.

Previous/next links point to wrong entities

Check the sort order in your View. The entity pager uses the view's result order to determine previous and next entities. Ensure your view is sorted correctly.

Token replacement not working in link text

Make sure the Token module is installed. Token replacement uses the entity context from either the previous/next entity (for prev/next links) or the current page entity (for the 'all' link).

Entity pager not appearing for certain entities

The entity pager only appears if the current entity is found in the view's results. Check that your view's filters include the current entity and that permissions allow viewing it.