Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I needed to display the number of referrers node for some cck node in a page that I was creating using a view.
I used this module to link the referrers node but I only needed there number, not a list of them.
So I edited: nodereferrer_view_handler_field.inc to add a drop down menu to enable this feature.
I get it to works but it's not nicely integrated at all so, if someone else want this feature ported into the module, it will be nice to have it in a final release.
(Still I've put my modified nodereferrer_view_handler_field.inc file for the 6.x-1.x dev and the patch with this request)
Comment | File | Size | Author |
---|---|---|---|
#33 | 416332_followup.patch | 1.11 KB | andypost |
#24 | 416332-24.patch | 1.88 KB | DeFr |
#19 | 416332.patch | 1.47 KB | DeFr |
nodereferrer_view_handler_field.inc.zip | 1.54 KB | Guillaume Schieber | |
nodereferrer_view_handler_field.patch | 9.39 KB | Guillaume Schieber |
Comments
Comment #1
andypostGood idea so need work to make more configurable
Comment #2
mansspams CreditAttribution: mansspams commentedI would need this but cannot provide code.
Comment #3
andypost@mansspams try code provided by @schibou
Comment #4
Guillaume Schieber CreditAttribution: Guillaume Schieber commented@mansspams the patch work's for me, you can try it.
Comment #5
mansspams CreditAttribution: mansspams commentedinstalled module, applied patch (replaced file from zip to be precise), added cck field, adjusted display (no count possibility there), tested how node looks, yes, nodes that refers to one i am looking at are displayed, so far so good. but in views i cannot find NodeReferrer field under content and got stuck there. I wonder what did i do wrong.
Comment #6
Guillaume Schieber CreditAttribution: Guillaume Schieber commentedHum I don't know why, maybe some chages in recent versions that make it obsolete.
It was not ported into the module (since it was just a one time application), sorry it didn't work for you.
Comment #7
andypost@schibou try to make a patch against current HEAD, I've made some cleanup
This feature is great! I glad to include this into upcoming release
Comment #8
mansspams CreditAttribution: mansspams commentedi found the problem. i was looking under content but it is under node, so yes, @schibou patchs works and you may include it in future releases. thanks guys!
Comment #9
mansspams CreditAttribution: mansspams commentedone more review?
Comment #10
mattiasj CreditAttribution: mattiasj commentedI would really need this functionality as well, thanks for the patch.
Comment #11
skizzo CreditAttribution: skizzo commentedAfter applying the patch the feature works properly for me. Thank you.
Comment #12
caschbre CreditAttribution: caschbre commentedI'm interested in this functionality. How would I go about applying the supplied patch?
Comment #13
andypost@caschbre try docs at http://drupal.org/patch/apply
Comment #14
andypostRequested filter to list nodes without referrers #582034: Integrate referrer count in views2
Suppose we need filter and formatter. Filter in count expression and formatter to display counts
Comment #15
skizzo CreditAttribution: skizzo commentedlooks like the OP patch does not apply to nodereferrer 6.x-1.0-beta2 dated 2009-09-22
Comment #16
marcushenningsen CreditAttribution: marcushenningsen commentedMight be that the patch doesn't work, but just copying nodereferrer_view_handler_field.inc into its place worked for me.
Thanks for this great feature. I used to make a forum with discussions with content types and views2.
I suggest you turn this feature into a separate field, enhances usability in my opinion.
Comment #17
andypostGlad to commit if someone provide a patch against DRUPAL-6 but not replacing existing features
Comment #18
marcushenningsen CreditAttribution: marcushenningsen commentedI'm afraid my php skills aren't sufficient to make a decent patch, but I'd love to help out in any way I can.
As I suggested above I'd prefer this feature in a separate handler: nodereferrer_view_handler_field_count.inc. This new handler should extend views_handler_field_numeric instead of views_handler_field since we are dealing with a numeric field.
andypost: I see that you've split up the handlers (nodereferrer_view_handler_field.inc, nodereferrer_view_handler_field_field.inc and nodereferrer_view_handler_field_type.inc), but I don't understand why? I don't know how much of the code should go into the new handler, since I don't really get what's going on in the code. Could you somehow lead me in the right direction?
Thanks
Marcus
Comment #19
DeFr CreditAttribution: DeFr commentedFirst of all, attaching a re-roll of the patch in this issue against the latest dev, and formatting it as a "real" patch.
@marcushenningsen in #18: the problem with that approach is that you'll need to duplicate pretty much all of the current code. Right now, nodereferrer_views_handler_field deals with common nodereferrer functions (as in, actually getting referrers, formatters options, stuff like that), and then both nodereferrer_views_handler_field_field and nodereferrer_views_handler_field_type inherits from that, and just customize the options form to let you select either specific fields or specific node types.
As a class can't have more than one parent in PHP, to have a class that extends views_handler_field_numeric, you'd need to implement the nodereferrer_views_handler_field_count handler, which would be mostly a copy of nodereferrer_views_handler_field with a rewritten render query, but then you'll *also* need to reimplement both nodereferrer_view_handler_field_field_count and nodereferrer_view_handler_field_type_count to base them on that new handler class. That's quite a lot of code duplication.
Supposing its done like that though, there would be two new fields in Views Field UI, resuling in something like:
That might be a bit easier on the end user, but that would also be a patch a lot bigger than the one attached.
@andypost: I guess it's your call :-)
Comment #20
andypost@DeFr this approach looks great! need more reviews and I glad to commit this!
Comment #21
caschbre CreditAttribution: caschbre commentedI'm interested in helping to test this. Do I just install the dev version and then apply the patch?
Comment #22
DeFr CreditAttribution: DeFr commented@caschbre: Yes. After applying the patch, you'll see a new option appearing in the field setting forms, Display referrers count:, defaulting to No. Switch it to Yes and the field will then display the referrers count instead of the referrers list.
Comment #23
andypostSuppose we need a new formatter for cck display not only for views and update docs
Comment #24
DeFr CreditAttribution: DeFr commentedRerolled with the count option as a field formatter instead of a view option. This approach upside is that it can be used everywhere and it doesn't add complexity to the Views field form: there's now a new option in the display as select instead, which means that you can choose to display the referrers as Node title, Node body... or Node count.
There's one downside though: Views easily let you alter the output a bit, which means the administrator can turn use this number in a sentence with one click on a case by case basis. It's not that easy in CCK land: developers will need to override the theme function, but that'll be site wide.
As it makes the code slightly prettier and it may be useful as a formatter nevertheless, I think I like this CCK field formatter approach best despite this problem though.
Comment #25
loominade CreditAttribution: loominade commentedsubscribing
Comment #26
andypostThanx, commited http://drupal.org/cvs?commit=307252
Comment #27
dicreat CreditAttribution: dicreat commentedAny solution to provide this count-fields for sorting in Views?
#663238: Option in Views to sort according to the count of referrers
Comment #29
sotiris CreditAttribution: sotiris commentedHas this feature included in the latest 6.x-1.0-rc1? I have installed it but i can see only Node: Nodereferrer: by field, and Node: Nodereferrer: by node type, inside my views at the add fields section...
Comment #30
sotiris CreditAttribution: sotiris commentedComment #31
andypostYes you right, choosing one
Node: Nodereferrer: by field
orNode: Nodereferrer: by node type
you can choose formatter for the field, the same at admin/content/node-type//displayDisplay fields
you can choose to display only count of referrers.It could be good if someone help me to update docs about this.
Comment #32
sotiris CreditAttribution: sotiris commentedThanks a lot for your help.
I used the second solution with display fields, and i've got my referrers counted. The only thing is that i got the following warning messages every first time that i call a node with the referrer field. When i called again the same node the warnings didn't appear.
The same warnings appeared again when i called other nodes with referrer field but only for the first time for every node.
warning: array_filter() [function.array-filter]: The first argument should be an array in /drupal-6.15/sites/all/modules/nodereferrer/nodereferrer.module on line 135.
warning: array_values() [function.array-values]: The argument should be an array in /drupal-6.15/sites/all/modules/nodereferrer/nodereferrer.module on line 135.
warning: array_filter() [function.array-filter]: The first argument should be an array in /drupal-6.15/sites/all/modules/nodereferrer/nodereferrer.module on line 136.
warning: array_values() [function.array-values]: The argument should be an array in /drupal-6.15/sites/all/modules/nodereferrer/nodereferrer.module on line 136.
Comment #33
andypostPlease try this patch
Comment #34
sotiris CreditAttribution: sotiris commentedAfter aplying your patch the warning messages doesn't appear any more.
Many thanks!
Comment #35
andypostcommited to HEAD and DRUPAL-6 so will be included in next release and -dev
Comment #37
bg1 CreditAttribution: bg1 commentedDoes the patch mentioned here give any ability to sort the nodereferrer results by the title of the referring node?
If not, is there some way to do that so the view results will display sorted?
Thanks.
Comment #38
Stomper CreditAttribution: Stomper commentedWould this work? https://drupal.org/project/nodereference_count