How to access $variables in a module function where $variables is not passed to it. (D7) I have a custom module that retrieves a view.

I would like to set a page variable that sums up a bunch of fields as im iterating through them.

So how to i access the $variables variable if it isnt an argument of my function?
Call your function from inside your module's preprocess_page() hook.  Eg, in your custom module, let's say your function that calls your view is mymodule_call_view().  Let's further assume it returns the value you want to set your page variable to.  You could do it this way:

mymodule_preprocess_page(&amp;$variables) {

  // any other preprocessing you are doing goes here

  $variables['variable_you_want_to_set']=mymodule_call_view();

}


Then, when drupal is building the page, it would call your preprocess function, which would call your function that iterates through the view, etc...