knackforge
December 16, 2011
Views one of the prevailing modules in Drupal. It has the competence to dwindle the manual work of pulling the data from the Drupal table and formatting them to meet our needs. Most of the developers might have known about the filter and the sort criterion in the views, but only a few know the exact way to display the current items and total result count in this view. Does this require acquaintance with coding? Apparently yes, but not as tedious as one would imagine. All it needs is a single-line PHP print statement in the view's template file.
Let's take an example view that was created with the intention to display the products node in a grid format. The machine's name in my view is the product.
The template file can be located within your views.
Once the above steps are over the custom template file will be used as the template file for the view in discussion.
How do show results and counts in a view? It's time to play with a few lines of code. Open the above-created file in a text editor of your choice. To display the views result count add the following snippet. This result can be placed at the top of the view's page. Hence I would prefer to place the custom code right above the $title in the template file.
The $view-> result indicates the array of result sets. The $view->total_rows holds the count of overall rows in the view.
Just like how your fellow techies do.
We'd love to talk about how we can work together
Take control of your AWS cloud costs that enables you to grow!