Drupal返回一个视图中的结果数 [英] Drupal return number of results in a View

查看:214
本文介绍了Drupal返回一个视图中的结果数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Drupal看到过滤我的内容。它带回7行。所有我想要返回的是返回的数字或结果(7)。这是可能吗?

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 View result counter but it returns a number for each results

1
2
3
4
5
6
7

1 2 3 4 5 6 7

我只需要7

所以在SQL中我会做一个选择计数(*)

So in SQL I would do a select count(*)

推荐答案

您可以做的是激活视图标题/页脚的php,并添加以下代码段:

what you can do is to activate php for the views header/footer and add the following snippet to it:

<?php
  $view = views_get_current_view();
  print $view->total_rows; 
?>

这将打印总行数。

如果您需要结果作为字段,则可以使用视图自定义字段模块,添加一个php字段并运行相同的代码段。

If you need the result as a field, you could use the "Views custom field" module, add a php field and run the same snippet.

注意

Mike

这篇关于Drupal返回一个视图中的结果数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆