Consider this scenario:

Parent node = "The Book"
Children = Chapter 1, 2, 3, 4, ...

Each chapter node type has a word count CCK field which keeps track of number of words (duh! :) How can I sum up the number of pages? ie. aggregate data from many child nodes?

I need this for current page count... Or would you consider a different approach? Maybe a hidden variable in the parent node?

Please advise. Thank you!

Comments

JohnG-1’s picture

views calc module ?
http://drupal.org/project/views_calc

    Install Views Calc module.
  1. Build a view that lists all the pages you want to include.
  2. Add the wordcount Field to the view.
  3. Set the View Type to Calc Table View.
  4. Then go to View Calc settings (admin/settings/views_calc)
  5. Enable calculations for your new view.
  6. Configure Fields (tab) ... set the wordcount column to Sum.
  7. Admire your work :)

Is that any good ? or were you after something a bit more elagant ?

andrew7’s picture

Title: Aggregate data from child nodes » That's awesome!

Thank you John,

Quite a creative and practical solution... Would you happen to have a suggestion for storing the count/sum within the parent node itself?

Anything with computer_field come to mind?

Thanx again. Cheers.

owahab’s picture

Title: That's awesome! » Aggregate data from child nodes
Priority: Normal » Minor
Status: Active » Closed (fixed)