Right now, if you add a Node Referrer field to a View, you can choose if the values returned by nodereferrer_view_handler_field::referrers should be displayed as a list or comma separated, but you don't have any control on the number of items that are displayed.
Such a setting can be usefull if you only want the field to display the last node that referenced a given node, instead of all of them.
Attached patch adds such a setting in nodereferrer_view_handler_field::options_form, and uses it in nodereferrer_view_handler_field::render to limit the displayed result.
Another approach would be to pass the maximum number of elements to retrieve all the way down to nodereferrer_referrers and use it as a LIMIT in the SQL-query: that would be a bit more efficient, but would make the patch a lot more invasive.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 594030-limit-number-of-items.patch | 2.67 KB | DeFr |
| allow-field-limit-form-setting.patch | 1.14 KB | DeFr |
Comments
Comment #1
andypostGreat addition!
Patch looks good for me. But I need more reviews to commit.
Comment #2
tpainton commentedApplied. Works as explained. Thanks!
Comment #3
willhowlett commentedWorks for me, thanks a million! When displaying multiple nodes it did cause duplicates of the node being referenced, but that was fixed by using the 'Distinct' option under the view's basic settings.
Comment #4
willhowlett commentedJust a thought. Do you think it would be possible to add a 'random' option here as well? I know I'd find that extremely useful.
Comment #5
devkinetic commentedWorked great for me as well, seconding a random option.
Comment #6
DeFr commentedOk, it seems like a randomize option is a popular idea, so here it goes, even though it's not strictly speaking related to the original bug report :-)
Note that the patch no longer applied cleanly to the DRUPAL-6--1 branch after the fix for #416332: Option in views to only display the number of referrers node ( count the child node of a cck node and display the number ), so I've rerolled it. Not sure why, but the 1.x-dev tarball wasn't regenerated after the commits on December 28, so it means that for now, the patch only applies cleanly to a CVS checkout of the DRUPAL-6--1 branch.
Comment #7
andypostThx, fixed http://drupal.org/cvs?commit=327598
So waiting for re-roll of new dev
Comment #8
DeFr commented@andypost: Looking at http://drupal.org/node/360732 I've noticed that it's following the HEAD branch of the repository, that's probably why it's not regenerating 1.x-dev when you commit on the 6--1 branch :-)
Comment #9
andypost@DeFr thanx for pointing a bug! Changed release to DRUPAL-6--1 branch http://drupal.org/node/360732
Comment #10
willhowlett commentedReally cool that you've done this. Many thanks