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.

Comments

andypost’s picture

Great addition!
Patch looks good for me. But I need more reviews to commit.

tpainton’s picture

Applied. Works as explained. Thanks!

willhowlett’s picture

Works 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.

willhowlett’s picture

Just 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.

devkinetic’s picture

Worked great for me as well, seconding a random option.

DeFr’s picture

StatusFileSize
new2.67 KB

Ok, 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.

andypost’s picture

Status: Needs review » Fixed

Thx, fixed http://drupal.org/cvs?commit=327598

So waiting for re-roll of new dev

DeFr’s picture

@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 :-)

andypost’s picture

@DeFr thanx for pointing a bug! Changed release to DRUPAL-6--1 branch http://drupal.org/node/360732

willhowlett’s picture

Really cool that you've done this. Many thanks

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.