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.
By JohnnyBeGood-dupe2 on
How can I show the total of nodes created under the relationship in a view?
I have a node type "product" and another one "type 2" with a product node reference.
What I want to show is more or less the following:
Product Number of "type 2" posts
A 4
B 7
C 3
D 0
E 1
... ...
and so on.
I only can find "comments count". there is no "node count"
How can I achieve it?
Thanks
Comments
I think you can do that with
I think you can do that with Computed Field
Thanks for your reply. As far
Thanks for your reply.
As far as I know computed field is only for CCK.
If there is a way probably is through views custom field.
But I have no idea how to get what I need with PHP code.
node reference is CCK.
node reference is CCK. You'll just need to do something like count($node->your_field) as your computed value.
If you go to the project page
If you go to the project page there is a link for documentation, and somewhere in there are lots of PHP code snippets. There is likely to be something similar to what you need.
You can access your computed
You can access your computed field in a view.
I don't want to have a
I don't want to have a computed field in the "child" node (what should I filled there? always 1?).
I just want to show the total of nodes created related to each product in a view.
I will try to find any snippets
Many thanks
Product Number of "type 2"
Your post is ambiguous. Are A, B, C Products or "type 2"? Less vague = better chance of somebody being able to help.
I'm sorry. I've typed a lot
I'm sorry.
I've typed a lot of spaces between the 2 columns, but they've gone.
I'll type "_" now.
Product_____________ Number of "type 2" posts
A __________________________ 4
B __________________________ 7
C __________________________ 3
D __________________________ 0
E __________________________ 1
Please read the "_" as blank
Thanks once again
Have
a look at the views customfield module, that should do the trick!
So, you want the number of
So, you want the number of "type 2" nodes that reference each "product" node?
You may want to use node referrer module, which will make your Products have back references back the the type 2 nodes that refer to them. Then you can use Computed Field or Views Custom Field
BTW, you can use
<code>
tag for literal text that won't have spaces stripped.http://drupal.org/project/nod
http://drupal.org/project/noderelationships is another module you might want to check out. I did not even know about it, but it looks interesting, and looks like it might do just what you need.
I will install those modules
I will install those modules to see if anyone fit my needs.
And I thought it would be a simple question!!!
Many many thanks once again
Same Problem
I am trying to figure out how to do the same thing so if you have any luck please let us know!
Quite simple, I've just
Quite simple, I've just needed to use a CustomField and insert the following code:
This gives us the total published nodes by the product referenced.
The CustomField module is very useful to show any information related with data produced by the query of the view.