Count number of nodes to be output I'm trying to figure out how many articles( nodes? ) will be displayed in a listing on our website, to use it to add classes to the elements that are rendered, so one can easily have different styling depending on the number of frontend elements. Right now there are six elements, so preprocess_node(&amp;$variables) is called 6 times in template.php in my theme, but:  How can I obtain the number of nodes in the preprocess_page() - hook?

The nodes seems to be produced by a Promoted articles - type of listing.
No need to modify template files. Instead create a view of Article content type and then follow the below steps.


Into view Header part add field Global: Result summary 
Now into above field configuration, inside Display text area add @total token.