Drupal 7视图3:显示显示节点的数量?示例:(显示5382个结果中的3842个)


Drupal 7 Views 3: Displaying the number of displayed nodes? Example: (Showing 3842 of 5382 results)

我们如何在视图中显示显示节点的数量?如:"显示5382个结果中的3842个"

如果视图中的所有节点同时显示,(通常是初始的),它可能会说:"显示所有5382个结果"

如果View中没有节点从过滤器中显示出来,它可能会说:"Found no results"

这很难吗?我认为这将是一个非常有用的补充,并感谢任何帮助。

我相信这可以做得更简洁。但我想说清楚我在做什么。这就是。基本上你可以在视图的页眉或页脚使用它。

<?php
$view = views_get_current_view();
$c = $view->total_rows;
$cp = $view->get_current_page();
$pp = $view->get_items_per_page();
$si = ($cp * $pp) + 1;
$ei = $si + ($pp - 1);
if($c > 0) {
  if($pp < $c) {
    if($ei > $c) {
      print "Showing $si to $c of $c results";
    } else {
      print "Showing $si to $ei of $c results";
    }
  } else {
    print "Showing all $c results";
  }
} else {
  print "Found no results";
}
?>

1)编辑视图

2)添加字段

3)全局:查看结果计数器

4)利润。