statistics_title_list($dbfield, $dbrows)
Returns the most viewed content of all time, today, or the last-viewed node.
string $dbfield: The database field to use, one of:
int $dbrows: The number of rows to be returned.
SelectQuery|FALSE A query result containing the node ID, title, user ID that owns the node, and the username for the selected node(s), or FALSE if the query could not be executed correctly.
function statistics_title_list($dbfield, $dbrows) { if (in_array($dbfield, array('totalcount', 'daycount', 'timestamp'))) { $query = db_select('node_field_data', 'n'); $query->addTag('node_access'); $query->join('node_counter', 's', 'n.nid = s.nid'); $query->join('users_field_data', 'u', 'n.uid = u.uid'); return $query ->fields('n', array('nid', 'title')) ->fields('u', array('uid', 'name')) ->condition($dbfield, 0, '<>') ->condition('n.status', 1) // @todo This should be actually filtering on the desired node status // field language and just fall back to the default language. ->condition('n.default_langcode', 1) ->condition('u.default_langcode', 1) ->orderBy($dbfield, 'DESC') ->range(0, $dbrows) ->execute(); } return FALSE; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!statistics!statistics.module/function/statistics_title_list/8.1.x