Count flags on user's content In my Drupal 7 site I want to display how many times user's content was flagged. 
As option I want to set a global variable counts and display it in different parts of *.tpl.php files. The value can be calculated with flag_get_counts($entity_type, $entity_id) for each user's node_id. Function that calculates counts should be called in template_page_preprocess() to update value each time page is reloaded. 

What is more efficient approach to implement this?
The right way is using template_preprocess_node().

Place the following code in template.php of your front end theme:

function YOUR_THEME_preprocess_node(&amp;$vars) {
  // I suppose you don't want to do this for every content type on the site.
  switch ($vars['node']-&gt;type) {
    case 'YOUR_CONTENT_TYPE':
      $vars['count'] = flag_get_counts('node', $vars['node']-&gt;nid);
      break;
  }
}


This will make the $count variable available in .tpl.php files that are used for displaying nodes of your content type.