carlcs/craft-elementstats

There is no license information available for the latest version (v1.0.2) of this package.

Element Stats widget for Craft CMS

Installs: 16

Dependents: 0

Suggesters: 0

Security: 0

Stars: 15

Watchers: 3

Forks: 0

Open Issues: 0

Type:craft-plugin

v1.0.2 2016-07-24 18:15 UTC

This package is auto-updated.

Last update: 2024-04-20 04:03:15 UTC


README

Element Stats

Installation

The plugin is available on Packagist and can be installed using Composer. You can also download the latest release and copy the files into craft/plugins/elementstats/.

$ composer require carlcs/craft-elementstats

Configuration

To configure the plugin you need to create a file named elementstats.php in the craft/config/ folder. This is where you configure the stats available in your widgets.

Place all of your stats configurations in a nested array with the key stats. The configurations themselves have to be arrays with an unique array key which will be used to identify the stat. Within that array you can use the following stat config settings:

  • name – What the stat will be called in the widget.
  • link – Where the link in your widget will lead. The setting expects a Control Panel URI.
  • elementType – What element type to fetch elements.
  • criteria – An array of element criteria parameters used to filter the elements.
  • dateColumn – What database column should be used for the time axis in the chart.
  • total – Allows you to manually set the value returned to the widgets.
  • numberFormat – How the value should be formatted in the widgets.

Element Stats widget comes with an example configuration file to give you a better idea of what types of data you can use and how to configure the stats configurations.

Here’s a very basic example:

return [
    'stats' => [
        'all-entries' => [
            'name'        => 'All Entries',
            'link'        => 'entries',
            'elementType' => 'Entry',
        ],
        'sports-news' => [
            'name'        => 'Sports News',
            'link'        => 'entries/news',
            'elementType' => 'Entry',
            'criteria'    => [
                'section' => 'news',
                'type'    => 'sports',
            ],
        ],
    ],
];

Requirements

  • PHP 5.4 or later
  • Craft CMS 2.6 or later