Is it possible to find out how many results are returned inside hook_views_pre_views() using Views 3 ?

What i've tried is to use $views->total_rows but that provides a false positive. I'm guessing because my view uses display suite to render the result?



 * Implements hook_views_pre_views()
function custom_views_pre_view(&$view, &$display_id, &$args) {
    if ($view->name == 'VIEW_NAME' && $display_id == 'block') {
        // Find out if results are empty; if so unset the view footer
        // Not sure what to do here?
        if ( ...) {
            // After rows check, unset my view footer which contains a view block
            $view->display_handler->options['footer'] = array();

Overall, i'm trying to programmatically unset the views footer. I've tried the "No Results" settings in the UI; but for some reason it always returns the child "View Area" i've attached in the View Footer.

  • The description for that hook is Allows altering a view at the very beginning of views processing, before anything is done. I would take that to mean that no query has been run yet, so there aren't any results to count. (that's assuming you meant hook_views_pre_view(), without the 's' at the end?) – Clive Sep 4 '13 at 15:08
  • I see i guess i'm asking the wrong question. Would you know which hooks would normally contain results? – chrisjlee Sep 4 '13 at 15:11
  • hook_views_pre_render() is pretty much guaranteed to contain the results (or an indication there were no results), and it happens early enough for you to alter rendering – Clive Sep 4 '13 at 15:16

Your Answer

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

Browse other questions tagged or ask your own question.