简体   繁体   English

Drupal 7 Display Hit / Page View counter

[英]Drupal 7 Display Hit / Page View counter

I want to display a counter on my website. 我想在我的网站上显示一个计数器。 The counter is to be done using Drupal, not by external providers. 该计数器将使用Drupal来完成,而不是通过外部提供商来完成。 On the net I've found these instructions: 在网上,我找到了以下说明:

Drupal 7 - Hit/Page View counter for Articles Another task I had to spend more time that I needed to. Drupal 7-文章的Hit / Page View计数器另一项任务是我必须花费更多的时间。 You would think that a simple hit counter would be a readily availble in a modual. 您会认为,简单的计数器很容易在模态中可用。 Anyway, heres what ya do: 无论如何,这是您的工作:

1) It's part of core; 1)它是核心的一部分; enable the core "Statistics" module. 启用核心“统计”模块。 You can see the official notes at : http://drupal.org/project/statistics_advanced 您可以在以下位置查看官方说明: http//drupal.org/project/statistics_advanced

2) Go to: Administration » Configuration » System » Statistics. 2)转到:管理»配置»系统»统计。 You may have to enable the "Statisctics" modual first. 您可能必须先启用“ Statisctics”模态。

3) For the setting "Content viewing counter settings" check the "Count content views" checkbox. 3)对于设置“内容查看计数器设置”,请选中“计数内容查看”复选框。

4) Be sure to set permissions for the module at admin/user/permissions, and configure it in admin/settings/statistics. 4)确保在admin / user / permissions设置模块的权限,并在admin / settings / statistics中进行配置。 IMPORTANT - On the giant Permissions panel, scroll down to the "Statistics" mod and enable permissions for "anoymous user" and "authenticated user" 重要信息-在庞大的“权限”面板上,向下滚动到“统计信息”模块,并启用“匿名用户”和“认证用户”的权限

5) You can now show the total count of the page hits, it should display in the block region you assigned. 5)您现在可以显示页面点击的总数,它应该显示在您分配的块区域中。

IMPORTANT - The block name is called "Popular Content". 重要信息-块名称称为“热门内容”。 Dont ask why. 不要问为什么。 You can see it working below: 您可以在下面看到它的工作方式:

5399 reads 5399阅读

I moved the popular content block into the correct region but it will not show me the number of hits only the most popular content pages. 我将受欢迎的内容块移到了正确的区域,但仅向最受欢迎的内容页面显示了点击数。 I would like to be able to show the number of hits. 我希望能够显示点击数。

Alternatives? 备择方案? How about a php-script? php脚本怎么样?
But where to put it: http://my-drupal-site.com/...path???.../counter.php 但是放在哪里: http : //my-drupal-site.com/...path???.../counter.php
What is the html-code to run the script and to show the result? 用于运行脚本和显示结果的html代码是什么?

(Please if you reply be aware of: I am drupal newbie, (如果您的答复是,请注意:我是Drupal新手,
experience status: 经验状态:
php: no PHP的:没有
html, css, linux, bash programming: yes) html,css,linux,bash编程:是)

Thanks 谢谢

You can use the visitors module to display the amount of visitors. 您可以使用访客模块来显示访客数量。

The module provides the following blocks: 该模块提供以下块:

  • Total Visitors. 访客总数。
  • Unique Visitor. 不重复访客。
  • Registered Users. 注册用户。
  • ... ...

I have solved this issue. 我已经解决了这个问题。 I have got the unique visitor count per node using "nodeviewcount.module". 我已经使用“ nodeviewcount.module”获得了每个节点的唯一访问者计数。 Just install this "nodeviewcount.module" module and then in my page.tpl.php I just fetched the result with the below code. 只需安装此“ nodeviewcount.module”模块,然后在我的page.tpl.php中,我使用以下代码获取了结果。

<?php

$query = 'SELECT COUNT(DISTINCT uid) FROM {nodeviewcount} WHERE nid='.$node->nid;
$unique_visitors = db_query($query)->fetchField();
print $unique_visitors.' views';
?>

I think this might help you. 我认为这可能对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM