tags:

views:

614

answers:

1

I am using Views 2 to get information from my Drupal 6 site. After getting the data, I want to use a little PHP to do some calculations that are unavailable through Views + Views calc. What is the best way to go about doing this?

I could alter the "Header" or "Footer" text, set the input format to "PHP Code", and try to access the $view object?

This didn't work for me:

<?php

global $view;
print_r($view);

?>

Any other ideas of what to do? What if I wanted to make an entire module that drew off existing Views instead of pulling info out of the db itself?

+1  A: 

There is a whole API for views, you may find that for your needs you can use a custom template and do the maths in that. If you are only using the calculations for output then this should be ok, even from a purists point of view.

If you need to do more than a little display logic, I think hook_views_pre_render() is the right hook for you.

Jeremy French