Hi KarenS,
I'm using the current dev snapshot and it works really well out of the box - thanks :)
Now I'm trying to use Views templates to reorganize the output of views data, but am running into difficulty knowing how to do this with views_calc totals.
Yesterday on IRC merlinofchaos was filling me in about the different syntax used for printing out individual field data within the various Views template types (like views-view-fields.tpl.php)... and I also asked how to print the output from contrib modules like views_calc. He wasn't sure about this last question, and I haven't been able to figure it out yet either.
What I'd like to do it print only the Total calculated from various individual fields (not just the complete last row that includes 'SUM' and all the rows, which I can already figure out how to do by overriding views-calc-table.tpl.php in my theme folder). The problem for me is the syntax... for instance, say I have 3 columns and I want to give a SUM or Average. How do I print just the total (AVG result) from row 2 only? etc.
Thanks in advance :)
Comments
Comment #1
scottrigbyPS, I'm marking some older issues as duplicate of this one, because it seems an answer to this would resolve those others as well. They're 5.x issues though and this issue is for 6.x – but those issues are kind of old – anyway to be safe, I'm listing them here (in case if I'm off base with marking as dupes):
#293012: only show results of calculation
#293790: display calculation as field
#296055: Referencing views calc results elsewhere...
#307092: theming fields
Comment #2
scottrigbyIn views-calc-table.tpl.php (copied from views_calc module and placed in my theme folder) this works:
print $totals[SUM]['my_field_name'];for SUM, etc.Comment #4
RobertNelsonVance commentedShould this not work within the view's header or footer.
For example, I have a view that adds the total of a column... I want to use the total within some text I have put in the view's footer.
I used the following in the view's footer and it won't print.
Comment #5
westie commentedI also would like to use totals vars in the views header / foot and am having no luck. Shed any light on if this is possible?
Comment #6
mautumn commented+1 subscribing. Exactly what I am try to do! I have had a look at the code and there doesn't appear to be a simple function to extract totals, averages, etc. The code is focused on looped themed content with running computations and it doesn't appear to expose its calculated values - which is a great shame. $totals looked promising but I have tried using $totals in the header php (using the excellent Views PHP module) and in views-calc-table--[my view name].tpl.php - but on each occasion it returns NULL :(
Comment #7
karens commentedThe D5 version is no longer supported.