Giter VIP home page Giter VIP logo

grav-plugin-count-views's Introduction

Count Views Plugin

The Count Views Plugin is for Grav CMS. It's a simple and naive page view counter.

Installation

Installing the Count Views plugin can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.

GPM Installation (Preferred)

The simplest way to install this plugin is via the Grav Package Manager (GPM) through your system's terminal (also called the command line). From the root of your Grav install type:

bin/gpm install count-views

This will install the Count Views plugin into your /user/plugins directory within Grav. Its files can be found under /your/site/grav/user/plugins/count-views.

Manual Installation

To install this plugin, just download the zip version of this repository and unzip it under /your/site/grav/user/plugins. Then, rename the folder to count-views. You can find these files on GitHub or via GetGrav.org.

You should now have all the plugin files under

/your/site/grav/user/plugins/count-views

NOTE: This plugin is a modular component for Grav which requires Grav and the Error and Problems plugins to operate.

Configuration

Before configuring this plugin, you should copy the user/plugins/count-views/count-views.yaml to user/config/plugins/count-views.yaml and only edit that copy.

Here is the default configuration and an explanation of available options:

enabled: true
datafile: count-views.yaml
  • The enabled field lets you turn the plugin off and on.

  • datafile is the path and name of the file that contains the count data, relative to user/data.

Usage

This is a simple, naive page view counter. Whenever the Grav system produces a page (cached or not), the route is stored and the count incremented. Obviously if you have a front-end cache that delivers the page without invoking index.php, then the view won't be counted. You also can't filter out views by IP or user (though pull requests are always welcome).

The full view count data is dumped as an associative array (i.e., route => count) into the Twig variable viewcounts. To support backwards compatibility, the counts are also still dumped into the config.plugins.count-views.counts namespace, but this is now officially deprecated and will be removed in a future major release.

Performance

Obviously there is a hit because the plugin has to access a physical file on the drive. In my personal experience, I haven't noticed any meaningful difference. Any suggestions to improve performance would be warmly welcomed.

grav-plugin-count-views's People

Contributors

perlkonig avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.