Download & Extend

Can I get the views_calc totals using view_get_view?

Project:Views Calc
Version:6.x-1.3
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I followed Nancy's extraordinary video tutorial on the Tracking the Fishing Tournament. It worked for our volunteer organization's requirements, except for one or two parts. I ended up needing several computed CCK fields, very much like the Results field where she is tracking the End of Year Totals and Rankings.

You run a custom query to calculate the latest totals and then update the totals fields in a referenced node. I wasn't able to update the referenced_node_fields by using the load_node($ref_nid) method; however I can run an UPDATE query and that works.

My problem is that each year we change volunteer web masters. Down the line, one of them may create another CCK node and use an "existing" field which could move the data to it's own Table and kill my customized get_the_totals query.

A better method might be to use "view_get_view(my_view_name)" which is a views_calc table. If I do that, what is the code syntax to add the arguments and get the views_calc fields, such as $this_total = [SUM]['my_field_name']?

Once I get all this working, I intend to write a How We Track Our Volunteer Hours article for Drupal.

Ashford

Comments

#1

Did you figure out how to do it ? thanks ;)

#2

Just this year I came up with a less technical approach so the volunteer web master could easily manage the site. Views Bulk Operations is the key module.

Example: Which of our volunteers has paid dues, have a minimum of 40 hrs service and 8 hrs training already this year to earn their 2011 Certification?

This is an abbreviated version just to show the essential process I am going to use.

Modules

  • CCK -custom node fields
  • Views -display node fields as lists
  • Views_Calc -total two fields
  • Views Bulk Operations -edit a field
  • Rules -used to redirect to an activity details node after member submits hours
  • Profile Role -real name needed for specific Role only in the Profile information. (We have web site users that are not Chapter members. We only need to track the Chapter Members statistical data.)

View -User Reference list

    List of members by Real Name to make available as a User Reference field
  • UID field (Do not display)
  • Real Name field (Profile)

Content Type: My Hours

    volunteers enter their hours
  • Member ID (User Reference)
  • Activity Date (Date)
  • Volunteer Service Hrs (Decimal)
  • Volunteer Travel Hrs (Decimal)
  • Volunteer Total Hrs (Computed field to add the 2 items above)
  • Volunteer Training Hrs (Decimal)

View -My Hours Activity Details list

    List of the logged in users previously recorded activities
  • Views Style: Table
  • Views Relationship: Member ID (User Reference)
  • Views Argument: default -User ID from logged in user
  • Views Filter: Node Type: My Hours
  • Views Fields: title, date, vol total hrs, vol training hrs, edit link so they can make corrections and it brings them back automatically to the view
  • Views Header: a link to Add to My Hours that opens the node/add/myhours

Rule -My Hours Activity Details list

    Rule -This allows the member to confirm their entry was successful and accurate.
  • On submit content type my hours
  • Redirect to /path/to/activity-details-page

Content Type: Member Stats

    Single node per volunteer created by the Membership Admin when they join the group
  • Title Automated with Tokens (Year Joined -Real name)
  • Member ID (User Reference)
  • Date Joined (Date)
  • Dues Paid Year (Date)
  • Certified This Yr (Date)

View -Dues list

    List of the members and year dues paid; treasurer can update Dues Paid field
  • Views Style: bulk operations -You select the fields the viewer can edit. In this case, Certified This Yr
  • Views Relationship: Member ID (User Reference)
  • Views Filter: Node Type: Member Stats
  • Views Fields: title, dues paid year

View -Certified list

    List of members and hours; Membership Admin can update Certified Date field

    I have not tested the Group By feature with Bulk Operations; but it should work. We are moving our site to another web host and all the attention is on the move right now.

  • Views Style: bulk operations -You select the fields the viewer can edit. In this case, Certified Date. Group By Member ID (User Reference)
  • Views Relationship: Member ID (User Reference)
  • Views Filter: Node Type: Member Stats; Node Type: My Hours; Dues Paid Yr = now; Activity Date field Yr = now
  • Views Fields: member stats: title, member stats: certified date, my hours: vol total hrs, my hours: vol training hrs

I hope that this makes sense and will help your situation.

#3

I tried it tonight. There is a problem with creating the View -Certified list. Views cannot handle the query with 2 content types. I thought having the user_reference in both Content_Types and using the Views Relationship function would work.

Views Filter: Node Type: Member Stats; Node Type: My Hours; Dues Paid Yr = now; Activity Date field Yr = now

There is a single Member Stats node per volunteer and multiple My Hours nodes. I wonder if a node_reference field to Member Stats would work in place of the user_reference?

The suggestion I saw on another Forum discussion was to create two separate Views and display them on the same page. In my case, I would want Member Stats for the bulk operations to update the field. My Hours is to view the hours totals to know when the member completes the minimum requirement. It could be a Block and displayed in the sidebar.

The alternative would be a custom module to run the query and display the page. I do not know Drupal programming nor the php programming well enough to do all the forms and actions through a custom module. Plus, I am trying to keep the site management simple for the next volunteer web master.

#4

I did find some new information on using code to get the view and add the arguments.

$view = views_get_view('guid_exists');
$view->set_arguments(array($rss_item->guid));
$view->execute();

I did not test this method on the views_calc table. My solution was to create the 2 views. The page view is the bulk operations to update the Member Stats node fields. A block view is displayed in the sidebar as a reference to view the total hours for each member.

#5

Here is a screen shop of the page with the 2 views.

AttachmentSize
bulk_operations_example2.jpg 113.98 KB

#6

Hi,

Where can I find Nancy's video tutorial on the Tracking the Fishing Tournament?

Thanks,

Paul

#7

http://www.archive.org/details/DrupalconBoston2008-TrackingEventResultsW...

Have paper and pencil handy. It was a DrupalCon workshop. She covers a lot of information in a short time, so it all moves along fast.

#8

Thanks!