fof/discussion-views

Add view counts to discussions

Maintainers

Package info

github.com/FriendsOfFlarum/discussion-views

Issues

Forum

Type:flarum-extension

pkg:composer/fof/discussion-views

Transparency log

Fund package maintenance!

Open Collective

Statistics

Installs: 26 840

Dependents: 4

Suggesters: 5

Stars: 1

2.0.0-rc.1 2026-08-17 06:52 UTC

This package is auto-updated.

Last update: 2026-08-17 06:54:13 UTC


README

MIT license Latest Stable Version Total Downloads

A lightweight discussion view tracker, with minimal settings and options.

Features

  • Tracks how many times a discussion has been viewed and displays it per discussion on the discussionlist, for guests and registered members alike. Note: by default a viewer is counted once per discussion per 15 minutes, so refreshing or navigating back to a discussion does not inflate its count — see View deduplication
  • Adds 2 sorting options: popular and unpopular
  • Adds 1 event which developers can listen for: DiscussionWasViewed - includes accessor IP and UserAgent strings
  • Adds 1 new permission where people can (re)set the viewcount of a discussion (default to admins)
  • Uses view_count column created on the discussions table, so should not impact load performance
  • Identify known crawlers with an option to not increase the view count for their visit. Uses jaybizzle/crawler-detect for identification

View deduplication

A viewer is counted at most once per discussion within a configurable window, 15 minutes by default. Registered members are identified by their user id, guests by their IP address; a view that can be attributed to neither is always counted.

The window is set in the admin panel, or directly as the fsdv.dedupe-ttl setting in seconds. Setting it to 0 disables deduplication and counts every view, as earlier versions did.

This keeps counts closer to the number of people who read a discussion rather than the number of requests made, and it removes a database write from most page loads — a refresh or a return visit costs a cache lookup instead.

Two consequences worth knowing:

  • Guests sharing an address (an office or a household behind one connection) are deduplicated against each other for that window. Registered members are not, as they key on their user id.
  • Deduplication uses Flarum's configured cache. No queue or Redis is required — the default file cache is enough — but clearing the cache lets recent viewers be counted again.

Installation

composer require fof/discussion-views:"*"

Links