1

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?

1

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(&$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...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.