doublesecretagency/craft-viewcount 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

doublesecretagency/craft-viewcount

最新稳定版本:2.0.0

Composer 安装命令:

composer require doublesecretagency/craft-viewcount

包简介

Count the number of times an element has been viewed.

README 文档

README

Plugin icon

View Count plugin for Craft CMS

Count the number of times an element has been viewed.

Example of View Count results

Track views via Twig, PHP, or AJAX

Basic tracking looks like this...

{% do craft.viewCount.increment(elementId) %}

However, there are several more advanced ways to increment a view counter.

Allow multiple counters on the same element

If you need to track multiple aspects of the same element, it's easy to do so! Simply specify an optional key when setting up the tracking mechanism.

Sort by "most viewed"

Once you've started logging views, you'll likely want to know which items have been viewed the most...

{% set articles = craft.entries.section('articles') %}
{% do craft.viewCount.sort(articles) %}

Display view totals in the control panel

You can add a "Total Views" field, which displays a read-only total for each element.

Events

They do exactly what you think...

  • EVENT_BEFORE_VIEW
  • EVENT_AFTER_VIEW

Within the EVENT_BEFORE_VIEW event, you can prevent the view from being counted.

Further Reading

If you haven't already, flip through the complete plugin documentation.

And if you have any remaining questions, feel free to reach out to us (via Discord is preferred).

On behalf of Double Secret Agency, thanks for checking out our plugin! 🍺

Logo for Double Secret Agency

统计信息

  • 总下载量: 13.92k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2019-01-22