Drupal return number of results in a View

前端 未结 6 1313
执念已碎
执念已碎 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 19:54

    If using views_get_view in Views 3, you can use this snippet:

        $view = views_get_view('MY_VIEW');
        $view->set_display('MY_DISPLAY');
        // Execute first
        $result = $view->preview('MY_DISPLAY');
        // Output result only if rows > 0
        if (count($view->result) > 0) {
          print $result;
        }
    

提交回复
热议问题