Does this function views_get_current_view inside views header or footer (to count rows number for example) means running the same view twice?
Or is it somewhat simplified version of running full view? Thank you.

  • What do you want to do exactly, you want to display count rows in header an footer of the view ?
    – berramou
    Nov 15, 2019 at 15:58
  • @berramou Or pull any data based on current view. My question is if this function means that the same view will run again just to get me this info (for example row number) or not.
    – loparr
    Nov 15, 2019 at 16:01
  • If you're using Views PHP filter thats bad for performance. Even the projects image says so.
    – No Sssweat
    Nov 15, 2019 at 16:48
  • @NoSssweat what do you suggest in this case then? thank you
    – loparr
    Nov 15, 2019 at 17:21
  • Views provides some tokens I think its @count that you can use in the header. If its something else other than counting use template_preprocess_views_view or hook_views_pre_render and do your logic there.
    – No Sssweat
    Nov 15, 2019 at 18:14

1 Answer 1


That function is just a wrapper for this function: https://api.drupal.org/api/views/views.module/function/views_set_current_view/7.x-3.x which will just return a reference to a static code cache.

Conclusion: no view gets run, it's just grabbing a copy of what's already been created.

In general, views is very efficient in such cases.

But I'd tend to agree with @berramou that you might have a better way of accomplishing what you really, really want.

  • thank you. By better solution you mean adding this code to module?
    – loparr
    Nov 15, 2019 at 18:02
  • Yes, you don't want to be putting code in the header/footer. But you might instead be able to accomplish what you want without custom code - most things I ever want to do with views have already been done and documented if you look hard enough.
    – Alan Dixon
    Nov 15, 2019 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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