Drupal return number of results in a View

前端 未结 6 1151
执念已碎
执念已碎 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:14

    This works well for me and deals with the pager issues. Put this function in your custom module, rename / format as needed, and call it from your views-view--*view_name_goes_here*.tpl.php files.

    function get_view_rowcount(){
    
     $view = views_get_current_view();
     $page_total = count($view->result);
     if(isset($view->total_rows)){
       return "Displaying " . $page_total . " of " . $view->total_rows . " total rows.";
     } else {
      return "Displaying " . $page_total . " of " . $page_total . " total rows.";
     }
    }
    

提交回复
热议问题