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

查看:22
本文介绍了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

1234567

我只需要 7 部分.

所以在 SQL 中我会做一个 select count(*)

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; 
?>

这将打印总行数.

如果您需要将结果作为字段,您可以使用视图自定义字段"module,添加一个 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.

问候

迈克

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

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