Drupal return number of results in a View

前端 未结 6 1153
执念已碎
执念已碎 2021-02-07 19:47

I have a view in Drupal that filters my content. It brings back 7 rows. All I want to return is the number or results returned(7). Is this possible?

I tried using the Vi

6条回答
  •  情深已故
    2021-02-07 20:06

    If you want to get the count outside the view you can use this

    $view = views_get_view('MY_VIEW_NAME');
    
    $view->set_display('MY_DISPLAY'); // like 'block_1'    
    
    $view->render();   
    
    print sizeof($view->result);
    

    Note : Do not use this within a view. It will be an overhead. If you are using it within view check the other answers.

提交回复
热议问题