在 drupal 中以编程方式更新 {node_counter} 表
我目前在 Drupal 6 安装上使用统计模块(核心)。每次查看节点时,都会增加 {node_counter} 表中的计数,并且这是有效的。
我的问题是 - 我也可以以编程方式增加这个计数器吗?我希望在用户与从视图创建的内容交互(例如单击灯箱)时实现这一目标,因此能够使用 AJAX 更新表格将是理想的选择。
我对 do 进行了快速搜索,似乎没有任何模块立即脱颖而出。有人有这方面的经验吗?
I currently use the statistics module (core) on my Drupal 6 install. This increments a count in the {node_counter} table every time the node is viewed, and this works.
My question is - can I programmatically increment this counter as well? I am looking to achieve this when users interact with content created from views (say click a lightbox), so being able to update the table with AJAX would be ideal.
I have done a quick search on d.o and there doesn't appear to be any modules that stick out straight away. Does anyone have any experience with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此制作一个自定义模块应该不难。
统计模块运行的查询是:
我们唯一需要做的就是将 arg(1) 替换为我们想要添加计数的节点 ID,这可以在自定义模块中完成像这样的东西。
剩下的就是实现一个自定义的访问控制函数,你可以检查请求是否是 ajax 或进行任何你喜欢的控制,该函数必须只返回 TRUE 或 FALSE。您还需要在设置中使用节点 id 创建一个 ajax 事件,但这也不应该太难。
您需要点击 url
custom/ajax/2
来更新 id 为 2 的节点等。It shouldn't be hard to make a custom module for this.
The query that the statistics module runs is:
The only thing we need to do, is to replace
arg(1)
with the node id we want to add a count to this could be done in a custom module something like this.All that's left is to implement a custom access control function, you can check if the request is ajax or make whatever control you like, the function must just return TRUE or FALSE. You also need to make a ajax event with the node id in your setting, but that shouldn't be too hard either.
You need to hit the url
custom/ajax/2
to update node with id 2 etc.