Closed (fixed)
Project:
Content Construction Kit (CCK)
Version:
6.x-2.8
Component:
nodereference.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Sep 2010 at 01:12 UTC
Updated:
13 Sep 2010 at 20:37 UTC
Comments
Comment #1
drupalnesia commentedYour subject is "Multiple nodes count in Views" but look like you asking about "number of nodes referred from a node reference field in Views".
Can you give a more clear example, so we can answer you with right answer.
Comment #2
shadysamir commentedLet me change the title accordingly
My real life example is: Content Type: Album, and Content Type: Song
Album has a node reference field called "Tracks" that refers to Song nodes and unlimited values allowed.
I want to display the number of tracks in that album (number of Song nodes referred in the field)
So the required view fields are:
Album Title
Number of tracks
Comment #3
shadysamir commentedComment #4
drupalnesia commentedNode_referencse used for a selectlist, you must manually select the value of Tracks.
If you want Album automatically show the number of its Tracks then I suggest to:
- Install http://drupal.org/project/computed_field
- Create a computed field, named as "Track"
- Use PHP script to return number of tracks/song according to Album ID (you may use $node->nid)
Comment #5
shadysamir commentedI will try that, thanks. Wondering how much of a performance hit it will be.
Comment #6
shadysamir commentedIt works. Thanks. I tested with my code and enhanced to match Counting the number of values in a multi value field and it does the trick. Of course I have to find a way to recalculate the field in all the nodes already there but that's beyond this issue.