PHP

How to get the total number of nodes displayed by the view

Technologies: 

There are times where we would want to view the total number of rows or data rows displayed in a view. The best way to do is to add a PHP snippet in the header section of a view. Fortunately, drupal views allow for adding code snippet into header and footer of a view.

However, this code snippet will work only if pager is enabled in the view. The code snippet:

<?php
  $view
= views_get_current_view();
  print
"<h4> Total Blood Banks: ".$view->total_rows." </h4>";
?>

In-case, you would want to get data from a particular view, you can provide the snippet:

Update Comment Status of a Node

Just recently I had the issue where a list of nodes imported via user import as a content profile had comment status disabled.

There were thousand of nodes to update, hence the best way was to use VBO. However, there was no option provided for comment status update, hence the alternative was to execute "Arbitrary PHP Code".

The following snippet below can be used for updating node status for nodes selected in VBO: