Problem/Motivation

Be able to hide the pager for when there are no other results to page through (1 or 0 results).

Proposed resolution

Add an option to the entity pager user interface.

Remaining tasks

  • Write implementation
  • Write tests

User interface changes

Add an option to the entity pager style options form.

API changes

Extra option value for the style plugin configuration.

Original report by zheleong

For Drupal 8 ,
1.please add option, hide pager if record only 1.
2.The token for "Next", "Prev", "Home" still not working
Thank you

Comments

zheleong created an issue. See original summary.

replicaobscura’s picture

Thanks for the suggestions!

I don't believe there's token support currently implemented for the link titles in the 8.x version of Entity Pager, but I would be happy to implement that functionality.

I'll break that second request off into a separate issue and use this one for tracking adding the option to hide the pager if there's only one result.

replicaobscura’s picture

Status: Needs work » Active

As there's no work done yet on this, setting the status to Active.

JmOkay’s picture

In version 7 I dealt with this by adding a touch of well placed meta data to the HTML cleverly positioned in the DOM to cover this scenario plus many others. This allows everybody from Front End people to Application Developers and Backend people to all easily adjust what is on the screen in a very simple and predictable place, without knowledge of the Module.

e.g.

I added an .inactive class to a span when the next / previous are not links.

e.g.
<span class="inactive">&lt; prev</span>

...so people can easily hide them as they wish via CSS.

I’ve also added to the ul a CSS class to give an indication on the number of records present:

e.g.
count_word_one
count_word_many

i.e.
<ul class="entity_pager count_word_one">

I could have added it as a number, but for privacy reasons I converted it to a string representation.

See: https://www.drupal.org/node/2784335

This approach solves this issue + https://www.drupal.org/node/2889495 + plus future unforeseen future requests in this area.

Hope this helps

JmOkay

firfin’s picture

The second part of the OP isn't adressed here yet it seems?
Anyways I made an issue for this specific question, maybe best to follow up there? As suggested by bmcclure in #3
Here it is #2920753: Changing labels has no effect

replicaobscura’s picture

The current code does actually include both the "inactive" class and the "count-word-[count]" class that can be used to target on the front-end. In the way, I suppose this is already supported if simply hiding on the front-end is what's desired.

I still think it might be a good idea to offer an option for this, since it seems like a very common requirement that shouldn't necessarily require custom code in the theme to accomplish. But at least it seems possible to do in the meantime.

wongjn’s picture

Title: Option hide pager if record only one » Option hide pager if record only one or zero
Issue summary: View changes
Related issues: +#3152737: One ID displaying multiple pagers

Update the scope of this issue slightly, rolling #3085355: I exclude pages by taxonomy terms, but pager shows in them anyway into this one. Edit: upon re-reading, slightly different contexts.

wongjn’s picture

Issue summary: View changes
wongjn’s picture

joachim’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
joachim’s picture

This is related to -- but not the same requirement as -- #3616326: entity pager shows (in disabled state) when not on an entity that's in the pager's list.

The solution may end up being similar -- we probably need a custom Block plugin so that we can hide the whole pager block based on the result of the view.