I have a view displayed with a node, and would like to use a field on the node to parametrize the number of results returned by the view. It's easy enough to get the value of that field into a contextual filter, but the pager doesn't parse tokens, so I can't do anything with it once I have it.

Patch in first comment updates the (non-date) pagers to check for tokens in items_to_show and offset fields. The alternative approach would be a separate pager plugin, which would be redundant in every way except parsing config options, but this seemed less desirable for long-term maintenance.

I tried to encourage some safety by ignoring tokens if those config options are exposed. I did not add tests (yet), figuring I'd ask for a sense of whether this functionality is even desirable first.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jproctor’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
8.57 KB
Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 4 year old patch in #1 does not apply to the latest views 7.x-3.x-dev and if still relevant needs to be rerolled.

Andrew Answer’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
8.26 KB

Patch rerolled.

Andrew Answer’s picture

jproctor’s picture

@Andrew Answer, thank you!

I tried applying your reroll to 3.22 (latest stable) and it failed in 3 places. All are because of #2885660: Warning: A non-numeric value encountered in views_plugin_pager_full->query(): 3.x-dev explicitly casts some things as (int) that 3.22 did not. I don’t want to lose that important change, so I added that back in.

This made me wonder if we had lost anything else since the original patch; I compared by re-rolling it against 3.22 and didn’t see anything.

Also I added a couple tests to make sure the tokens are being interpolated.

Andrew Answer’s picture

@jproctor,

thank you for adding tests. I always re-roll patches to the last dev module version at the moment of my work; it allow me to use Drupal patch testing system immediately to control quality.

Look here: https://www.drupal.org/node/1054616 "Do not attempt to create or apply patches to git tags. This causes trouble for not only you, but everyone else trying to use your patch. Except in very specific and unusual cases, patch development should generally be done on branches."